{"id":16,"date":"2011-09-17T04:50:52","date_gmt":"2011-09-17T04:50:52","guid":{"rendered":"http:\/\/blog.mozilla.org\/nfroyd\/?p=16"},"modified":"2011-09-17T04:50:52","modified_gmt":"2011-09-17T04:50:52","slug":"notes-from-the-all-hands-profiling-bof","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nfroyd\/2011\/09\/17\/notes-from-the-all-hands-profiling-bof\/","title":{"rendered":"notes from the all-hands profiling bof"},"content":{"rendered":"<p>After talking to a couple people at all-hands, it became clear that writing your own profiler was a popular activity.\u00a0 (Jeff Muizelaar informed me that last year, the pet project was heap analyzers.\u00a0 What&#8217;s next for 2012?)\u00a0 A short, non-exhaustive list:<\/p>\n<ul>\n<li>Patrick Walton&#8217;s <a href=\"https:\/\/github.com\/pcwalton\/piranha\">Piranha profiler for Android<\/a><\/li>\n<li>Benoit Girard&#8217;s <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=683229\">Simple Profiling System<\/a><\/li>\n<li>Luke Wagner&#8217;s <a href=\"http:\/\/hg.mozilla.org\/users\/lwagner_mozilla.com\/measure\/\">measure profiler<\/a><\/li>\n<li>The ever-venerable <a href=\"http:\/\/hg.mozilla.org\/mozilla-central\/file\/tip\/tools\/jprof\">jprof<\/a><\/li>\n<li>Steve Fink mentioned that he had a profiler for JavaScript code<\/li>\n<\/ul>\n<p>&#8230;and so forth.\u00a0 So it seemed like getting interested parties together to talk about One Profiler to Rule Them All would be good.\u00a0 And it worked; we had probably 20 people come to the BoF.\u00a0 Below is my summary\/recollection of what we discussed..\u00a0 All the omissions and\/or misrepresentation in the notes are my own; please leave a comment if you felt I left something out or need to describe something better.<\/p>\n<p>What does the ideal profiler look like?<\/p>\n<ul>\n<li>Cross-platform<\/li>\n<li>Low overhead, both when profiling and not<\/li>\n<li>Collects more-or-less complete call stacks (this is fairly easy everywhere except x86\/Linux)<\/li>\n<li>Understands compiled\/interpreted JavaScript and C\/C++ code<\/li>\n<li>Built with the browser itself, not an external process or loaded via <tt>LD_PRELOAD<\/tt> or similar; this means we can ship it with the browser and diagnose problems in the field<\/li>\n<li>Pretty pictures for viewing collected data.\u00a0 Who doesn&#8217;t love pretty pictures, right?<\/li>\n<\/ul>\n<p>Bas Schouten also pointed out that it might be much more efficient to just buy suitable profiling technology from a vendor; there was some skepticism that a profiler fulfilling the desiderata existed, though.<\/p>\n<p>Since Benoit gave a demo of his profiler and his profiler seems likely to get into the tree, most of the discussion centered around that or variantions thereof.\u00a0 Benoit&#8217;s profiler works in the usual way via periodic signaling; however, instead of unwinding the call stack, Benoit chose to require annotations (via RAII objects) placed in various parts of the code to indicate what your &#8220;callstack&#8221; was when a sample was taken.\u00a0 I believe Steve said his profiler does something similar for JavaScript.\u00a0 I put &#8220;callstack&#8221; in quotes because you only get to know whether functions were on the call stack if annotations had been placed in them.<\/p>\n<p>Sprinkling annotations all over the tree sounded like a tedious process.\u00a0 Somebody pointed out that Chrome does this, though they only place annotations at &#8220;entry points&#8221; for modules, so you might have one entry point for layout, one for graphics, etc. etc.\u00a0 That way, given a profile on some random performance bug, you can at least tell who should be exploring the bug further with minimal overhead, since you&#8217;re not unwinding and a handful of RAII objects isn&#8217;t going to cost much.\u00a0 Granted, this doesn&#8217;t do much for the folks who need to dig deeper, but perhaps we can have other tools for that.<\/p>\n<p>There was some discussion of unwinding instead of annotations.\u00a0 Unwinding is reasonably cheap when using libunwind and caching decoding of the unwind information; it&#8217;s even cheaper when you can just walk frame pointers.\u00a0 The only wrinkle is you aren&#8217;t guaranteed to have frame pointers or unwind information on x86\/Linux, so unwinding is not generally doable there.\u00a0 Sometimes assembly coders also forget they need to insert unwind annotations, though most if not all of the problematic code in glibc, at least, has been so annotated.\u00a0 Taras Glek suggested that we could insert RAII objects before calling out to code that we don&#8217;t control and to make those objects record something about frame\/stack pointers so that we could unwind around third-party code if necessary.\u00a0 I don&#8217;t believe we came to a consensus on using unwinding instead of or in addition to annotations.<\/p>\n<p>I can&#8217;t recall if we talked extensively about unwinding through JavaScript code.<\/p>\n<p>We didn&#8217;t talk about displaying the collected data.\u00a0 Drawing pretty, understandable pictures is hard.<\/p>\n<p>Benoit and Steve agreed to talk further offline about modifying Benoit&#8217;s profiler to understand JavaScript; if you&#8217;d like to help with profilers, talk to either of them.\u00a0 It&#8217;d be great to have something in the tree that we can all work with and improve.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After talking to a couple people at all-hands, it became clear that writing your own profiler was a popular activity.\u00a0 (Jeff Muizelaar informed me that last year, the pet project was heap analyzers.\u00a0 What&#8217;s next for 2012?)\u00a0 A short, non-exhaustive list: Patrick Walton&#8217;s Piranha profiler for Android Benoit Girard&#8217;s Simple Profiling System Luke Wagner&#8217;s measure [&hellip;]<\/p>\n","protected":false},"author":320,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/posts\/16"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/users\/320"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}