{"id":100,"date":"2008-05-03T02:30:12","date_gmt":"2008-05-03T07:30:12","guid":{"rendered":"http:\/\/www.visophyte.org\/blog\/?p=100"},"modified":"2009-04-01T08:32:49","modified_gmt":"2009-04-01T13:32:49","slug":"master-control-pecobro-the-overkill-performance-code-browser","status":"publish","type":"post","link":"https:\/\/www.visophyte.org\/blog\/2008\/05\/03\/master-control-pecobro-the-overkill-performance-code-browser\/","title":{"rendered":"master control pecobro, the overkill performance code browser"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"169\" class=\"alignnone size-full wp-image-101\" title=\"pecobro-01\" src=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-01.png\" alt=\"\" srcset=\"https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-01.png 650w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-01-600x156.png 600w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-01-300x78.png 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>The title isn&#8217;t true yet, but it&#8217;s disturbingly almost-true.\u00a0 Pecobro&#8217;s hackish underpinnings have been &#8220;accidentally&#8221; replaced with surprisingly forward-looking code capable of supporting a much fancier feature set.\u00a0 (I didn&#8217;t mean to, but I got tricked because the incremental cost to doing the &#8216;right thing&#8217; was always so low.)<\/p>\n<p>The trace that <a href=\"http:\/\/clicky.visophyte.org\/examples\/pecobro\/20080503-01\/index.xml\">you can see here, by clicking on any of this text what has coloring<\/a> (and using firefox 3 in a session that you don&#8217;t mind if it crashes), is of running <a href=\"http:\/\/ccgi.standard8.plus.com\/blog\/\">Mark Banner (Standard8)<\/a>&#8216;s Thunderbird bloatTest on OS X with DTrace probes enabled, but without actually doing the bloat testing.\u00a0 So Thunderbird starts up, opens the address book, closes it, opens the compose window, closes it, and then quits.<\/p>\n<p><a href=\"http:\/\/clicky.visophyte.org\/examples\/pecobro\/20080503-02\/index.xml\">Here is a preliminary processed trace<\/a> from a run triggering <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=296453\">bug 296453<\/a>.\u00a0 Be forewarned that there is some missing information from the underlying trace and so it&#8217;s not all that it could be.\u00a0 I think the XPConnect probes need to be fleshed out slightly more (and processed).<\/p>\n<p>The code (both pecobro and mozilla codebase patches) is at: <a href=\"http:\/\/hg.mozilla.org\/users\/bugmail_asutherland.org\/\">http:\/\/hg.mozilla.org\/users\/bugmail_asutherland.org\/<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"517\" height=\"153\" class=\"alignnone size-full wp-image-102\" title=\"pecobro-02\" src=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-02.png\" alt=\"\" srcset=\"https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-02.png 517w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-02-300x88.png 300w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/p>\n<p>What crazy overkill things can pecobro do now?<\/p>\n<ul>\n<li>Parse all of the javascript code used in Thunderbird, including nearly all (maybe all?) of the 1.x enhancements.\u00a0 The parser is still a bit hackish, especially when it comes to support of regexes, but it actually parses things.\u00a0 Thanks to Chris Lambrou for posting his initial JavaScript.g antlr3 grammar (and BSD licensing it) that I used as a basis for my hacky version.\u00a0 This was certainly a learning experience; I now know that javascript can never replace python in my heart&#8230;<\/li>\n<li>Find all of the places functions can be defines in javascript code and do a pretty good job at figuring out reasonable names for them.\u00a0 This even includes &#8220;<em>(<\/em>new<em>)?<\/em> Function()&#8221;.\u00a0 This allows us to use the function-info DTrace probes to use line number information to identify functions.\u00a0 We do this so that we can identify anonymous functions.<\/li>\n<li>Handle XBL as well as we handle pure-javascript files.\u00a0 (Parsing\/AST fix-ups\/syntax highlighting with AST traversal\/etc.)<\/li>\n<li>Parse\/interpret disturbingly large portions of makefiles.\u00a0 Sure, it ignores the rules, and I&#8217;ve only implemented the functions I require, but it does all the conditional and include stuff with variable expansion, including some key functions like foreach\/filter\/etc.<\/li>\n<li>Parse jar manifests sufficiently well to figure out what file ends up at what chrome path.<\/li>\n<li>Cache its javascript parse results at both the AST and (sorta-semantic) processing level, among other things.\u00a0 Hooray for <a href=\"http:\/\/home.gna.org\/oomadness\/en\/cerealizer\/index.html\">cerealizer<\/a> which dares persist\/de-persist that which pickle dare not.\u00a0 (Nested classes.)\u00a0 (Note: We don&#8217;t cache XBL stuff yet, and the ASTs are large enough that de-persisting them can be quite perceptible.)<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"556\" height=\"222\" class=\"alignnone size-full wp-image-103\" title=\"pecobro-03\" src=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-03.png\" alt=\"\" srcset=\"https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-03.png 556w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2008\/05\/pecobro-03-300x119.png 300w\" sizes=\"auto, (max-width: 556px) 100vw, 556px\" \/><\/p>\n<p>What is not crazy, but still nice:<\/p>\n<ul>\n<li>The traces are now much more reliable thanks to modifications to the Mozilla USDT probes to provide sufficient information for us to distinguish between JavaScript execution contexts (namely, JSContext).\u00a0 Modifications were also made to avoid the &#8216;guessing&#8217;\/ghost value problems that happen when native functions were called.<\/li>\n<li>A foolish bug in the sparkbar calculation has been fixed.\u00a0 aka &#8220;Now With Accuracy&#8221;!<\/li>\n<li>If a function in a trace called another function or was called by another function, this will be displayed inline in the source display.<\/li>\n<li>Infer &#8216;native&#8217; functions (with the above additional modifications to the Mozilla USDT probes), assigning them to an object.\u00a0 This ends up being Object, ChromeWindow, or other native Class type.\u00a0 Some of this may be mooted by getting the XPConnect probes reliably in the mix.<\/li>\n<\/ul>\n<p>What doesn&#8217;t it do?<\/p>\n<ul>\n<li>Add the XPConnect js_Invoke probes; I punted on that because that was turning out to be difficult to get right.<\/li>\n<li>It ignores .xul files for now.\u00a0 Although xul files primarily appears in a caller context (as told by function-info probes), they can also be a callee when someone pulls a fast one and inlines some simple code in a script tag.\u00a0 We brutally mis-attribute the call to the previous function when this happens.\u00a0 This will eventually get resolved because we will need to understand .xul files for namespace reasons.\u00a0 Also, people sound like they&#8217;re interested in who overlays what and the like, and that&#8217;s sorta right up our alley thanks to all the overkill stuff we do.<\/li>\n<li>Exhaustively determine reads from\/contributions to the &#8216;global&#8217; (window or what not) namespace\/scope.\u00a0 The groundwork is there in terms of understanding the contribution of top-level statements to the namespace or its reads from it, but we don&#8217;t traverse into functions.<\/li>\n<li>Associate functions with an object\/type (ignoring the native function case).\u00a0 This requires more semantic understanding.<\/li>\n<li>Clicking on functions still doesn&#8217;t do anything.\u00a0 I disabled that before my first post on pecobro due to firefox-crashing issues, and still haven&#8217;t gotten around to resolving it.<\/li>\n<li>A usable overview visualization.\u00a0 The overview diagram has become cluttered by the presence of so many &#8216;relevant&#8217; (touched) files.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The title isn&#8217;t true yet, but it&#8217;s disturbingly almost-true.\u00a0 Pecobro&#8217;s hackish underpinnings have been &#8220;accidentally&#8221; replaced with surprisingly forward-looking code capable of supporting a much fancier feature set.\u00a0 (I didn&#8217;t mean to, but I got tricked because the incremental cost &hellip; <a href=\"https:\/\/www.visophyte.org\/blog\/2008\/05\/03\/master-control-pecobro-the-overkill-performance-code-browser\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[7,3,8,4],"tags":[48,50,26,39,51],"class_list":["post-100","post","type-post","status-publish","format-standard","hentry","category-debugging","category-mozilla","category-program-execution","category-visualizing","tag-dtrace","tag-js","tag-pecobro","tag-visophyte","tag-xbl"],"_links":{"self":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":2,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":261,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts\/100\/revisions\/261"}],"wp:attachment":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}