{"id":2040,"date":"2012-06-27T17:17:41","date_gmt":"2012-06-27T06:17:41","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=2040"},"modified":"2012-06-27T17:17:41","modified_gmt":"2012-06-27T06:17:41","slug":"memshrink-progress-week-53-54","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2012\/06\/27\/memshrink-progress-week-53-54\/","title":{"rendered":"MemShrink progress, week 53-54"},"content":{"rendered":"<p>Week 53-54?\u00a0 We&#8217;ve been going for over a year!\u00a0 To celebrate MemShrink&#8217;s 1st birthday, I wrote about <a href=\"http:\/\/blog.mozilla.org\/nnethercote\/2012\/06\/15\/memshrinks-1st-birthday\/\">the major achievements we&#8217;ve made in the past year<\/a>.<\/p>\n<h3>Memory Reporting<\/h3>\n<p>I overhauled the cross-cutting &#8220;Other Measurements&#8221; shown for JavaScript in about:memory.\u00a0 It&#8217;s now in two parts.\u00a0 The first part is a functional breakdown of the memory consumption of the main JavaScript runtime, i.e. all JavaScript memory usage outside of web worker threads.\u00a0 Here&#8217;s an example.<\/p>\n<pre>194,179,064 B (100.0%) -- js-main-runtime\r\n\u251c\u2500\u2500159,064,360 B (81.92%) -- compartments\r\n\u2502\u00a0 \u251c\u2500\u2500\u250073,850,880 B (38.03%) -- gc-heap\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u250022,014,080 B (11.34%) -- objects\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0 \u251c\u2500\u250014,119,616 B (07.27%) \u2500\u2500 non-function\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0 \u2514\u2500\u2500\u25007,894,464 B (04.07%) \u2500\u2500 function\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u250019,553,168 B (10.07%) \u2500\u2500 unused-gc-things\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u250014,014,208 B (07.22%) -- shapes\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0 \u251c\u2500\u2500\u25006,747,240 B (03.47%) \u2500\u2500 tree\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0 \u251c\u2500\u2500\u25004,926,000 B (02.54%) \u2500\u2500 dict\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u2502\u00a0 \u2514\u2500\u2500\u25002,340,968 B (01.21%) \u2500\u2500 base\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u250010,204,960 B (05.26%) \u2500\u2500 strings\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500\u25005,338,816 B (02.75%) \u2500\u2500 scripts\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500\u25001,493,472 B (00.77%) \u2500\u2500 type-objects\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500\u25001,229,456 B (00.63%) \u2500\u2500 arena-admin\r\n\u2502\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u25002,720 B (00.00%) \u2500\u2500 sundries\r\n\u2502\u00a0 \u251c\u2500\u2500\u250029,459,680 B (15.17%) \u2500\u2500 analysis-temporary\r\n\u2502\u00a0 \u251c\u2500\u2500\u250014,484,704 B (07.46%) \u2500\u2500 script-data\r\n\u2502\u00a0 \u251c\u2500\u2500\u250013,062,744 B (06.73%) \u2500\u2500 string-chars\r\n\u2502\u00a0 \u251c\u2500\u2500\u2500\u25009,300,704 B (04.79%) -- shapes-extra\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u251c\u2500\u25003,325,952 B (01.71%) \u2500\u2500 compartment-tables\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u251c\u2500\u25002,845,984 B (01.47%) \u2500\u2500 tree-tables\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u251c\u2500\u25002,125,056 B (01.09%) \u2500\u2500 dict-tables\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u2514\u2500\u25001,003,712 B (00.52%) \u2500\u2500 tree-shape-kids\r\n\u2502\u00a0 \u251c\u2500\u2500\u2500\u25007,688,912 B (03.96%) -- type-inference\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u251c\u2500\u25005,750,576 B (02.96%) \u2500\u2500 script-main\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u251c\u2500\u25001,368,560 B (00.70%) \u2500\u2500 object-main\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u2514\u2500\u2500\u2500\u2500569,776 B (00.29%) \u2500\u2500 tables\r\n\u2502\u00a0 \u251c\u2500\u2500\u2500\u25006,232,272 B (03.21%) -- objects\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u251c\u2500\u25004,406,720 B (02.27%) \u2500\u2500 slots\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u251c\u2500\u25001,726,640 B (00.89%) \u2500\u2500 elements\r\n\u2502\u00a0 \u2502\u00a0\u00a0\u00a0 \u2514\u2500\u2500\u2500\u2500\u250098,912 B (00.05%) \u2500\u2500 misc\r\n\u2502\u00a0 \u251c\u2500\u2500\u2500\u25004,256,768 B (02.19%) \u2500\u2500 cross-compartment-wrappers\r\n\u2502\u00a0 \u2514\u2500\u2500\u2500\u2500\u2500\u2500727,696 B (00.37%) \u2500\u2500 mjit-data\r\n\u251c\u2500\u2500\u250019,472,384 B (10.03%) -- gc-heap\r\n\u2502\u00a0\u00a0 \u251c\u2500\u250018,006,016 B (09.27%) \u2500\u2500 unused-arenas\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500\u25001,458,176 B (00.75%) \u2500\u2500 chunk-admin\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u25008,192 B (00.00%) \u2500\u2500 decommitted-arenas\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25000 B (00.00%) \u2500\u2500 unused-chunks\r\n\u2514\u2500\u2500\u250015,642,320 B (08.06%) \u2500\u2500 runtime<\/pre>\n<p>The contents of the &#8220;js-main-runtime\/compartments&#8221; sub-tree is the sum of all the individual compartment entries in the &#8220;explicit\/js&#8221; sub-tree, and the &#8220;js-main-runtime&#8221; total is the same as the &#8220;explicit\/js&#8221; total.\u00a0 This new view will become more important when <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=687724\">per-tab memory reporting<\/a> is implemented which will cause each tab&#8217;s JavaScript memory consumption to be reported separately.<\/p>\n<p>The second part is designed to show the utilization of the garbage-collected heap.\u00a0 The new measurements and presentation are more detailed and easier to understand than the old version.\u00a0 Here&#8217;s an example.<\/p>\n<pre>93,315,072 B (100.0%) -- js-main-runtime-gc-heap-committed\r\n\u251c\u2500\u250055,755,888 B (59.75%) -- used\r\n\u2502\u00a0 \u251c\u2500\u250053,068,256 B (56.87%) \u2500\u2500 gc-things\r\n\u2502\u00a0 \u251c\u2500\u2500\u25001,458,176 B (01.56%) \u2500\u2500 chunk-admin\r\n\u2502\u00a0 \u2514\u2500\u2500\u25001,229,456 B (01.32%) \u2500\u2500 arena-admin\r\n\u2514\u2500\u250037,559,184 B (40.25%) -- unused\r\n\u00a0\u00a0 \u251c\u2500\u250019,553,168 B (20.95%) \u2500\u2500 gc-things\r\n\u00a0\u00a0 \u251c\u2500\u250018,006,016 B (19.30%) \u2500\u2500 arenas\r\n\u00a0\u00a0 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25000 B (00.00%) \u2500\u2500 chunks<\/pre>\n<p>One thing this makes clear is that our &#8220;unused&#8221; fraction is often very high.\u00a0 We&#8217;ll need a compacting generation garbage collector to really fix that.\u00a0 This is being actively worked on, but it&#8217;s a large task.<\/p>\n<p>Nathan Froyd had a productive couple of weeks.<\/p>\n<ul>\n<li>He <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=752952\">added a memory reporter nsIDocument&#8217;s property tables<\/a>.<\/li>\n<li>He <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=765344\">measured some more stuff under the &#8220;xpti-working-set&#8221; reporter<\/a>.<\/li>\n<li>He <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=765326\">measured some more stuff under the &#8220;atom-table&#8221; reporter<\/a>, renaming it &#8220;atom-tables&#8221; in the process.<\/li>\n<li>He <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=747509\">measured some more stuff in the DOM multi-reporter<\/a>.<\/li>\n<\/ul>\n<p>These four reporters don&#8217;t cover a great deal of memory, but that&#8217;s inevitable these days;\u00a0 all the low-handing &#8220;heap-unclassified&#8221; fruit is gone, and the remaining improvements will necessarily be small.\u00a0 We&#8217;re gradually closing in on the <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=563700\">target of 10%<\/a>, though I&#8217;m not sure we&#8217;ll ever get there.<\/p>\n<p>Nils Maier <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=759783\">added some more identifying information to JavaScript sandboxes<\/a>, which will help identify them in about:memory.<\/p>\n<p>Bas Schouten <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=738189\">added a memory reporter for VRAM used by Azure<\/a>.<\/p>\n<h3>Fixed Leaks<\/h3>\n<p>Robert O&#8217;Callahan <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=731868\">fixed a leak involving canvas<\/a>, which I won&#8217;t pretend to understand.\u00a0 This also fixed <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=757749\">bug\u00a0 757749<\/a>.<\/p>\n<p>Cervantes Yu <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=764773\">fixed a B2G memory leak that would leak about 1MB of memory per day<\/a>.\u00a0 This was found by Valgrind, under the operation of Julian Seward.<\/p>\n<h3>Quote of the Week<\/h3>\n<p>A Hacker News thread contained the following <a href=\"http:\/\/news.ycombinator.com\/item?id=4123346\">comment<\/a>.<\/p>\n<blockquote><p><span style=\"color: #737373;\">Mozilla needs to focus on making its browser consume less memory and CPU when idle. These are the things that are killing its marketshare and leading users to switch to alternatives. Every time I see initiatives like the password account manager, iOS apps that use web view, a browser based editor and what not I just scratch my head because Firefox marketshare is plummeting and the old refrain &#8220;just wait until the next version&#8221; was tired since 3.0. Instead the general response is to get defensive and list new features. Yeah and are those new features stopping the user drain? Nope. Firefox is a sluggish memory sucking heap of software that drains resources even when it isn&#8217;t being used.<\/span><\/p>\n<p><span style=\"color: #737373;\">I love and cherish Firefox as a product and a brand, because you have achieved a lot in your past. But now you are failing and it is depressing to see this happen.<\/span><\/p><\/blockquote>\n<p>That&#8217;s not the quote of the week, BTW;\u00a0 I&#8217;ve heard variations of that many times before, and while it had some truth to it 18 months ago, that piece of conventional wisdom is now well past its use-by date.\u00a0 Pleasingly, there was quite a bit of push-back in response.\u00a0 My favourite <a href=\"http:\/\/news.ycombinator.com\/item?id=4123656\">comment<\/a>, which <em>is<\/em> the quote of the week, was the following.<\/p>\n<blockquote><p>Firefox is to Ford what Chrome is to Toyota. Even if Firefox is as reliable and efficient as Chrome these days, some people still see it as being the gas-guzzling unreliable Ford vehicle of yesteryear.<\/p><\/blockquote>\n<p>A bad reputation is a difficult thing to lose.<\/p>\n<h3>Bug Counts<\/h3>\n<p>Here are the current bug counts.<\/p>\n<ul>\n<li>P1: 23 (-2\/+0)<\/li>\n<li>P2: 87 (-10\/+9)<\/li>\n<li>P3: 106 (-3\/+3)<\/li>\n<li>Unprioritized: 2 (-2\/+2)<\/li>\n<\/ul>\n<p>A net change of -2 P1 bugs, and -1 P2 bugs.\u00a0 Not bad!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Week 53-54?\u00a0 We&#8217;ve been going for over a year!\u00a0 To celebrate MemShrink&#8217;s 1st birthday, I wrote about the major achievements we&#8217;ve made in the past year. Memory Reporting I overhauled the cross-cutting &#8220;Other Measurements&#8221; shown for JavaScript in about:memory.\u00a0 It&#8217;s now in two parts.\u00a0 The first part is a functional breakdown of the memory consumption [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4550,30,4544,4546],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/2040"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/users\/139"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/comments?post=2040"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/2040\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=2040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=2040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=2040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}