jsprobes cross platform browser instrumentation using
play

jsprobes cross-platform browser instrumentation using - PowerPoint PPT Presentation

jsprobes cross-platform browser instrumentation using JavaScript Brian Burg (@brrian / burg@cs.uw.edu) Background: browser research template 1 2 3


  1. jsprobes ¡ ¡ cross-platform browser instrumentation using JavaScript Brian Burg (@brrian / burg@cs.uw.edu)

  2. Background: ¡ ¡ browser ¡research ¡template ¡ 1 ¡ 2 ¡ 3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ Become ¡puzzled ¡ Get ¡real ¡data ¡ Write ¡paper ¡ by ¡a ¡ques:on ¡ and ¡analyze ¡ with ¡answers ¡ images ¡from ¡www.phdcomics.com ¡

  3. Right ¡now, ¡this ¡is ¡the ¡hard ¡part ¡ 1 ¡ 2 ¡ 3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ Become ¡puzzled ¡ Get ¡real ¡data ¡ Write ¡paper ¡ by ¡a ¡ques:on ¡ and ¡analyze ¡ with ¡answers ¡ images ¡from ¡www.phdcomics.com ¡

  4. Browser ¡instrumenta:on ¡wishlist ¡ • Cross-­‑plaForm/architecture ¡ • Low/no ¡performance ¡overhead ¡ • Shareable/distributable ¡ • Run:me ¡flexibility ¡ • Familiar ¡programming ¡model ¡ • Cross-­‑language/cross-­‑component ¡

  5. Exis:ng ¡approaches: ¡ browser ¡addons/extensions ¡ Advantages ¡ Disadvantages ¡ • Somewhat ¡familiar ¡ • Can’t ¡access ¡all ¡parts ¡ programming ¡model ¡ of ¡the ¡stack ¡ • Easy ¡to ¡distribute ¡ • Bad ¡for ¡cri:cal ¡path ¡ instrumenta:on ¡ • Cross-­‑plaForm ¡ • Flexibility ¡at ¡run:me ¡ Image: ¡Mozilla ¡Test ¡Pilot ¡(www.mozillalabs.com/testpilot/) ¡

  6. Exis:ng ¡approaches: ¡ plaForm ¡instrumenta:on ¡ Advantages ¡ Disadvantages ¡ • Extremely ¡low/no ¡ • Needs ¡escalated ¡(root) ¡ performance ¡overhead ¡ privileges/kernel ¡mod ¡ • Can ¡instrument ¡any ¡ • PlaForm-­‑specific ¡ browser ¡component ¡ • Limited ¡programming ¡ • Run:me ¡flexibility ¡ language/model ¡ • Cannot ¡distribute ¡ Images: ¡dtrace.org, ¡en.wikipedia.org/wiki/SystemTap ¡

  7. Exis:ng ¡approaches: ¡ modifying ¡browser ¡source ¡ Advantages ¡ Disadvantages ¡ • Can ¡do ¡anything! ¡ • Difficult ¡to ¡understand ¡ and ¡modify ¡ • (possible) ¡low ¡ • Easy ¡to ¡cause ¡crashes ¡ performance ¡impact ¡ • Hard ¡to ¡distribute/ share/reuse ¡ • Very ¡fragile ¡vs. ¡ upstream ¡changes ¡

  8. jsprobes : ¡an ¡experiment ¡ • A ¡browser ¡instrumenta:on ¡framework… ¡ ¡ – With ¡instrumenta:on ¡wri_en ¡in ¡JavaScript ¡ – Accessible ¡via ¡XPCOM ¡to ¡addons ¡ – Available ¡on ¡all ¡plaForms/architectures ¡ – Which ¡encourages ¡experimenta:on ¡ – That ¡can ¡gather ¡many ¡kinds ¡of ¡data ¡ – Fast ¡enough ¡to ¡gather ¡low-­‑level ¡data ¡

  9. jsprobes ¡terminology ¡ probe ¡point ¡ probe ¡handler ¡ probe ¡values ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ Source ¡loca:on ¡ What ¡to ¡do ¡at ¡ Data ¡to ¡record ¡ to ¡instrument ¡ probe ¡point ¡ at ¡probe ¡point ¡ images ¡from ¡www.phdcomics.com ¡

  10. jsprobes ¡use ¡case ¡ 1. ¡Find ¡an ¡interes:ng ¡probe ¡point ¡ probes.GC_DID_START probes.GC_DID_START 2. ¡Decide ¡which ¡probe ¡values ¡to ¡use ¡ env.currentTimeMS env.currentTimeMS, , runtime.heapSize runtime.heapSize 3. ¡Write ¡a ¡probe ¡handler ¡for ¡that ¡point ¡ ¡ pendingGC pendingGC = [ = [env.currentTimeMS env.currentTimeMS, 0, , 0, runtime.heapSize runtime.heapSize, 0]; , 0];

  11. jsprobes ¡use ¡case ¡(2) ¡ 4. ¡Write ¡a ¡matching ¡handler ¡to ¡ GC_WILL_END GC_WILL_END: pendingGC pendingGC[1] = [1] = env.currentTimeMS env.currentTimeMS; ; pendingGC pendingGC[3] = [3] = runtime.heapSize runtime.heapSize; ; data.push data.push(pendingGC pendingGC); ); ¡ 5. ¡Register ¡handlers ¡with ¡the ¡probes ¡service. ¡ 6. ¡Periodically ¡fetch ¡data ¡and ¡do ¡something, ¡ such ¡as ¡aggregate, ¡graph, ¡or ¡report ¡it.

  12. Demo! ¡ (source ¡available ¡at ¡h_ps://bitbucket.org/burg/aboutgc) ¡ ¡

  13. jsprobes ¡architecture ¡ Handler ¡registry ¡ ¡ ¡ ¡ ¡ Main ¡browser ¡ ¡ Probe ¡handler ¡ thread ¡+ ¡heap ¡ thread ¡+ ¡heap ¡

  14. jsprobes ¡architecture ¡ Handler ¡registry ¡ ¡ probe handler code ¡ probe handler code ¡ ¡ probe handler code Register ¡probe ¡ handler ¡with ¡service ¡ Main ¡browser ¡ ¡ Probe ¡handler ¡ thread ¡+ ¡heap ¡ thread ¡+ ¡heap ¡

  15. jsprobes ¡architecture ¡ Probe ¡point ¡reached. ¡ Handler ¡registry ¡ 1 ¡ ¡ probe handler code ¡ probe handler code ¡ ¡ probe handler code Register ¡probe ¡ handler ¡with ¡service ¡ Main ¡browser ¡ ¡ Probe ¡handler ¡ thread ¡+ ¡heap ¡ thread ¡+ ¡heap ¡

  16. jsprobes ¡architecture ¡ Probe ¡point ¡reached. ¡ Data ¡gathered, ¡ serialized, ¡ and ¡enqueued ¡ Handler ¡registry ¡ ¡ probe handler code ¡ probe handler code ¡ ¡ probe handler code Register ¡probe ¡ handler ¡with ¡service ¡ Main ¡browser ¡ ¡ Probe ¡handler ¡ thread ¡+ ¡heap ¡ thread ¡+ ¡heap ¡

  17. jsprobes ¡architecture ¡ Data ¡gathered, ¡ asynchronously ¡ serialized, ¡ deserialize ¡data ¡ and ¡enqueued ¡ and ¡run ¡handlers ¡ Handler ¡registry ¡ ¡ probe handler code ¡ probe handler code ¡ ¡ probe handler code Register ¡probe ¡ handler ¡with ¡service ¡ Main ¡browser ¡ ¡ Probe ¡handler ¡ thread ¡+ ¡heap ¡ thread ¡+ ¡heap ¡

  18. jsprobes ¡architecture ¡ Data ¡gathered, ¡ asynchronously ¡ serialized, ¡ deserialize ¡data ¡ and ¡enqueued ¡ and ¡run ¡handlers ¡ Handler ¡registry ¡ ¡ probe handler code ¡ probe handler code ¡ ¡ probe handler code Register ¡probe ¡ handler ¡with ¡service ¡ Main ¡browser ¡ ¡ Probe ¡handler ¡ thread ¡+ ¡heap ¡ thread ¡+ ¡heap ¡ Post ¡async ¡messages ¡ back ¡to ¡main ¡thread ¡

  19. jsprobes ¡architecture ¡ Data ¡gathered, ¡ asynchronously ¡ serialized, ¡ deserialize ¡data ¡ and ¡enqueued ¡ and ¡run ¡handlers ¡ Handler ¡registry ¡ ¡ probe handler code ¡ probe handler code ¡ ¡ probe handler code Register ¡probe ¡ handler ¡with ¡service ¡ Dispatch ¡message ¡to ¡callbacks ¡ Probe ¡handler ¡ thread ¡+ ¡heap ¡ Main ¡browser ¡ ¡ Post ¡async ¡messages ¡ thread ¡+ ¡heap ¡ back ¡to ¡main ¡thread ¡

  20. Architecture ¡implica:ons ¡ • Probe ¡points ¡can ¡fire ¡at ¡:mes ¡unsafe ¡for ¡JS ¡ • Probe ¡handlers ¡have ¡read-­‑only ¡access* ¡ • Handler ¡must ¡specify ¡what ¡data ¡to ¡collect ¡ • Probe ¡data ¡must ¡be ¡representable ¡in ¡JS ¡ • Probe ¡data ¡must ¡be ¡be ¡serializable** ¡ * ¡Side-­‑effects ¡would ¡complicate ¡ ** ¡Probe ¡data ¡is ¡marshalled ¡using ¡ reasoning ¡when ¡mul:ple ¡ the ¡HTML ¡5 ¡structured ¡cloning ¡ handlers ¡are ¡registered ¡for ¡the ¡ algorithm. ¡This ¡can ¡be ¡extended ¡ ¡ same ¡probe ¡point ¡ to ¡support ¡new ¡data ¡types. ¡

  21. jsprobes: ¡current ¡status ¡ • Cross-­‑plaForm/architecture ¡ • Low/no ¡performance ¡overhead ¡ (TODO) ¡ • Shareable/distributable ¡ (TODO) ¡ • Run:me ¡flexibility ¡ • Familiar ¡programming ¡model ¡ • Cross-­‑language/cross-­‑component ¡ Current ¡implementa:on ¡available ¡at ¡h_ps://bitbucket.org/burg/jsprobes-­‑patches ¡ ¡

  22. Let’s ¡fill ¡in ¡the ¡research ¡template… ¡ 1 ¡ 2 ¡ 3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ 3 ¡ ¡ ¡ Use ¡jsprobes ¡to ¡ ¡ ¡ ¡ Implement ¡beLer ¡ ¡ “Do ¡websites ¡have ¡a ¡ make ¡an ¡addon ¡ ¡ ¡ ¡ heap ¡size ¡heurisMcs ¡ typical ¡heap ¡size?” ¡ that ¡measures ¡ ¡ based ¡on ¡real ¡data ¡ ¡ ¡ per-­‑site ¡heap ¡size ¡ images ¡from ¡www.phdcomics.com ¡

  23. Future ¡work ¡ • More ¡sophis:cated ¡implementa:on ¡ – No ¡“probe ¡effect” ¡when ¡probes ¡inac:ve ¡ – Low ¡performance ¡impact ¡when ¡ac:ve ¡ • Add ¡probe ¡points ¡to ¡more ¡components ¡ • Expose ¡more ¡types ¡of ¡data ¡to ¡probe ¡handlers ¡ ¡Brian ¡Burg ¡– ¡University ¡of ¡Washington ¡ ¡burg@cs.uw.edu ¡ ¡www.brrian.net ¡ ¡ www.twi_er.com/brrian ¡ ¡ ¡h_ps://bitbucket.org/burg/ ¡ h_p://brrian.tumblr.com ¡ ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend