{"id":2362,"date":"2012-11-14T16:17:07","date_gmt":"2012-11-14T05:17:07","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=2362"},"modified":"2012-11-14T16:17:07","modified_gmt":"2012-11-14T05:17:07","slug":"memshrink-progress-week-73-74","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2012\/11\/14\/memshrink-progress-week-73-74\/","title":{"rendered":"MemShrink progress, week 73&#8211;74"},"content":{"rendered":"<p>B2G!\u00a0 Fennec!\u00a0 Social API!\u00a0 They&#8217;re all happening, and memory consumption is a big deal for all of them.\u00a0 Time for a MemShrink report.<\/p>\n<h3>B2G<\/h3>\n<p>Lots of B2G work is happening, unsurprisingly.\u00a0 All of these changes have been backported to the Aurora channel.<\/p>\n<p>Kyle Huey <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=798491\">landed an important patch that merges system compartments together<\/a>.\u00a0 This avoids wasted space caused by having 100s of small compartments.\u00a0 As Chris Jones <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=798491#c60\">said:<\/a> &#8220;It&#8217;s a completely different phone with these patches.&#8221;\u00a0 Unfortunately, the preference controlling this behaviour is currently turned off on B2G, because it&#8217;s causing some Marionette test failures.\u00a0 Hopefully they&#8217;ll be dealt with soon.\u00a0 Note that this preference won&#8217;t be turned on in desktop builds, and there&#8217;s a <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=759585\">medium-term plan<\/a> to avoid this wasted space in a less hacky fashion.<\/p>\n<p>Marco Bonardo <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=799609\">disabled Places in B2G<\/a>, saving about 300 KiB in the main process.<\/p>\n<p>Justin Lebar added code to trigger memory pressure events when lowmemkiller notifications occur.<\/p>\n<p>Justin also <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=809587\">tweaked things so that the garbage collector is more likely to run when screenshots are taken<\/a>.<\/p>\n<p>Jeff Muizelaar <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=805689\">fixed a graphics bug<\/a> that I don&#8217;t understand but apparently avoids allocating lots of memory on the B2G unlock screen.<\/p>\n<p>Chris Jones <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=806029\">ensured that\u00a0remote content drop their buffers when they&#8217;re hidden<\/a>.<\/p>\n<p>I <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=811132\">tweaked the size of the arena chunks used by XPT<\/a>, which saved about 120 KiB per process on 64-bit builds, and a bit less on 32-bit builds.<\/p>\n<p>I also <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=807896\">shrunk the initial size of the SPS hash table<\/a>, which saves 48 KiB per process on 64-bit builds and 24 KiB on 32-bit builds.<\/p>\n<h3>Memory Reporting<\/h3>\n<p>Lots of work happened on the memory reporting front.\u00a0 This was inspired by\u00a0 &#8220;heap-unclassified&#8221; typically being much higher on B2G than on desktop.\u00a0 Desktop Firefox uses a single process and its memory consumption is usually measured in the 100s of MiBs or more.\u00a0 In contrast, B2G uses one &#8220;main&#8221; process and then one process per running app, and the smaller ones are typically around 10 MiB.\u00a0 As a result, the sundry small per-process things that don&#8217;t matter much for desktop loom larger on B2G.\u00a0 (For the same reason, changes that reduce per-process memory by smallish amounts have outsize value on B2G.)\u00a0 Most of the following changes have also been backported to the Aurora channel.<\/p>\n<p>Nick Hurley <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=699951\">added a &#8220;explicit\/network\/disk-cache&#8221; memory reporter<\/a>.\u00a0 It typically measures 100s of KiBs in desktop Firefox.\u00a0 (It doesn&#8217;t get used on B2G.)<\/p>\n<p>I <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=807884\">added memory reporters &#8220;explicit\/xpcom\/component-manager&#8221; and &#8220;explicit\/xpcom\/category-manager&#8221;<\/a>.\u00a0 Together they measure about 280 KiB per process on 64-bit builds, and a bit less on 32-bit builds.<\/p>\n<p>I <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=807850\">added a memory reporter &#8220;explicit\/script-namespace-manager&#8221;<\/a>.\u00a0 It measures just over 150 KiB per process on 64-bit builds, and a bit less on 32-bit builds.<\/p>\n<p>I <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=802894\">added a memory reporter &#8220;explicit\/xpcom\/effective-TLD-service&#8221;<\/a>.\u00a0 It measures about 128 KiB per process on 64-bit builds, and a bit less on 32-bit builds.<\/p>\n<p>I <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=806283\">added some detail to the JS object memory reporters<\/a>.\u00a0 This gives slightly more insight into where this memory is going, but the extra memory measured as a result is usually pretty small.<\/p>\n<p>I <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=810215\">fixed the &#8220;explicit\/atom-tables&#8221; memory reporter<\/a>, which was erroneously always reporting 0 bytes.\u00a0 It now measures anywhere from a few 100 KiBs to several MiBs of memory.\u00a0 This was a frustrating bug to find.\u00a0 <a href=\"https:\/\/wiki.mozilla.org\/Performance\/MemShrink\/DMD\">DMD<\/a> exists to check that memory reporters are measuring memory properly, and the reporter was doing its measurements just fine.\u00a0 But DMD cannot check that the measured amounts are added correctly, and that&#8217;s what was going wrong here &#8212; a line that should have been this:<\/p>\n<pre><code>return n;<\/code><\/pre>\n<p>instead was this:<\/p>\n<pre><code>return 0;<\/code><\/pre>\n<p>In other words, the code I had written was doing the difficult part correctly, but botched the trivial part.\u00a0 How annoying.<\/p>\n<h3>Social API<\/h3>\n<p>Felipe Gomes <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=803255\">fixed a document leak<\/a> that occurred when the social sidebar was hidden, and disappeared only when it was unhidden.<\/p>\n<p>Felipe also <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=807532\">added code to clear the previous profile when Social is toggled off<\/a>, which prevents a leak.<\/p>\n<p>The social API still has some\u00a0<a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=805246\">significant unresolved memory consumption issues<\/a>, which are a concern.<\/p>\n<h3>Fennec<\/h3>\n<p>Kartikaya Gupta (a.k.a. Kats) turned on <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=803575\">tab expiration<\/a> for Fennec.\u00a0 What this means is that Fennec will now unload the contents of background tabs in certain circumstances &#8212; when memory is low, and in some cases when a tab hasn&#8217;t been viewed for over an hour &#8212; and then reload them when they are brought back into the foreground.\u00a0 Read Kats&#8217; <a href=\"https:\/\/staktrace.com\/spout\/entry.php?id=782\">blog post<\/a> for more details.<\/p>\n<p>(This change was prompted by <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=792131\">Project 256meg<\/a>, which aims to make Fennec usable on phones with only 256 MiB of RAM.\u00a0 (Fennec currently requires 512 MiB, according to the <a href=\"http:\/\/www.mozilla.org\/en-US\/firefox\/mobile\/platforms\/\">official specs<\/a>.)\u00a0 Kats has just got to the point where Fennec can <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=792131#c1\">actually start<\/a> on 256 MiB devices.\u00a0 Although Fennec only uses a single process, there is obviously significant overlap between this goal and B2G&#8217;s memory reduction goals.)<\/p>\n<p>An obvious follow-up idea is to add tab expiration to desktop Firefox.\u00a0 But the <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=675539\">bug tracking that idea<\/a> has seen more heated discussion.\u00a0 The reason is that tab expiration might cause data loss in some cases.\u00a0 This is less of a problem on Fennec because (as far as I can tell) there is less of an expectation that in-flight data will be saved on mobile devices.\u00a0 For example, having processes killed due to memory constraints on mobile is much more common than on desktop.\u00a0 Still, I expect plenty more arguing before this issue is resolved one way or the other.\u00a0 One option is to allow it on desktop but have it disabled by default.<\/p>\n<h3>Add-ons<\/h3>\n<p>Michel Gutierrez <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=795633\">fixed a zombie compartment in Video DownloadHelper<\/a>, which is the 2nd most popular add-on at AMO. \u00a0 Version 4.9.11 has the fix.<\/p>\n<p>We hit a notable milestone on the add-on front this fortnight:\u00a0 on November 1st hit <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=700547\">bug for tracking known leaks in add-ons<\/a> &#8212; filed 16 months ago &#8212; had zero blockers.\u00a0 In other words, we reached the point where no add-ons were known to leak!\u00a0 Unfortunately this didn&#8217;t last long, and at the time of writing the tracking bug has three blocking bugs.\u00a0 Still, it&#8217;s confirmation that what used to be our biggest memory consumption problem is well under control.<\/p>\n<h3>Bug Counts<\/h3>\n<p>Here are the current bug counts.<\/p>\n<ul>\n<li>P1: 20 (-3\/+5)<\/li>\n<li>P2: 110 (-10\/+7)<\/li>\n<li>P3: 102 (-3\/+8)<\/li>\n<li>Unprioritized: 4 (-2\/+4)<\/li>\n<\/ul>\n<p>As always, the current bug lists can be found by following the <a href=\"https:\/\/wiki.mozilla.org\/Performance\/MemShrink#Bug_Tracking\">links on the MemShrink wiki page<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>B2G!\u00a0 Fennec!\u00a0 Social API!\u00a0 They&#8217;re all happening, and memory consumption is a big deal for all of them.\u00a0 Time for a MemShrink report. B2G Lots of B2G work is happening, unsurprisingly.\u00a0 All of these changes have been backported to the Aurora channel. Kyle Huey landed an important patch that merges system compartments together.\u00a0 This avoids [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4550,119,4261,451,30,4544,4546],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/2362"}],"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=2362"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/2362\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=2362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=2362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=2362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}