<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nicholas Nethercote</title>
	<atom:link href="http://blog.mozilla.org/nnethercote/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mozilla.org/nnethercote</link>
	<description>Notes on Firefox, MemShrink, JavaScript, and more</description>
	<lastBuildDate>Fri, 14 Jun 2013 14:03:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>MemShrink&#8217;s 2nd Birthday</title>
		<link>http://blog.mozilla.org/nnethercote/2013/06/15/memshrinks-2nd-birthday/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/06/15/memshrinks-2nd-birthday/#comments</comments>
		<pubDate>Fri, 14 Jun 2013 14:03:31 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[B2G]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Memory consumption]]></category>
		<category><![CDATA[MemShrink]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2623</guid>
		<description><![CDATA[June 14, 2013 is the second anniversary of the first MemShrink meeting.  This time last year I took the opportunity to write about the major achievements from MemShrink&#8217;s first year.  Unsurprisingly, since then we&#8217;ve been picking fruit from higher in &#8230; <a href="http://blog.mozilla.org/nnethercote/2013/06/15/memshrinks-2nd-birthday/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>June 14, 2013 is the second anniversary of the first MemShrink meeting.  This time last year I took the opportunity to write about <a href="https://blog.mozilla.org/nnethercote/2012/06/15/memshrinks-1st-birthday/">the major achievements from MemShrink&#8217;s first year</a>.  Unsurprisingly, since then we&#8217;ve been picking fruit from higher in the tree, so the advances have been less dramatic.  But it&#8217;s been 11 months since I last update the <a href="https://blog.mozilla.org/nnethercote/2012/07/11/memshrink-progress-week-55-56/">&#8220;big ticket items&#8221; list</a>, so I will take this opportunity to do so, providing a partial summary of the past year at the same time.</p>
<h3>The Old Big Ticket Items List</h3>
<h4>#5: Better Script Handling</h4>
<p>This had two parts.  The first part was the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=679942">sharing of immutable parts of scripts</a>, which Till Schneidereit implemented.  It can save multiple MiBs of memory, particular if you have numerous tabs open from the same website.</p>
<p>The second part is <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=678037">lazy bytecode generation</a>, which Brian Hackett has implemented and landed, though it hasn&#8217;t yet enabled.  Brian is working out the remaining kinks and hopes to land by the end of the current (v24) cycle.    Hopefully he will, because measurements have shown that it can reduce Firefox&#8217;s memory consumption by 5% or more on common workloads!  That&#8217;s a huge, general improvement.  Furthermore, it significantly reduces the number of things that are allocated on the GC heap (i.e. scripts, strings, objects and shapes that are created when bytecode for a function is generated).  This reduces pressure on the GC which makes it less likely we&#8217;ll have bad GC behaviour (e.g. pauses, or too much memory consumption) in cases where the GC heuristics aren&#8217;t optimal.</p>
<p>So the first part is done and the second is imminent, which is enough to cross this item off the list.  [Update:  Brian <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=678037#c93">just enabled lazy bytecode on trunk</a>!]</p>
<h4>#4: Regain compartment-per-global losses</h4>
<p>Bill McCloskey implemented <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=759585">zones</a>, which restructured the heap to allow a certain amount of sharing between zones. This greatly reduced wasted space and reduced memory consumption in common cases by ~5%.</p>
<p>Some more could still be done for this issue.  In particular, it&#8217;s not clear if things have improved enough that many small JSMs can be used without wasting memory.  Nonetheless, things have improved enough that I&#8217;m happy to take this item off the list.</p>
<h4>#3: Boot2Gecko</h4>
<p>This item was about getting about:memory (or something similar) working on B2G, and using it to optimize memory.  This was done some time ago and the memory reporters (plus DMD) were enormously helpful in improving memory consumption.  Many of the fixes fell under the umbrella of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=797189">Operation Slim Fast</a>.</p>
<p>So I will remove this particular item from the list, but memory optimizations for B2G are far from over, as we&#8217;ll see below.</p>
<h4>#2: Compacting Generational GC</h4>
<p>See below.</p>
<h4>#1: Better Foreground Tab Image Handling</h4>
<p>See below.</p>
<h3>The New Big Ticket Items List</h3>
<h4>#5: pdf.js</h4>
<p>pdf.js was recently made the default way of opening PDFs in Firefox, replacing plug-ins such as Adobe Reader.  While this is great in a number of respects, such as security, it&#8217;s not as good for memory consumption, because <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=881974">pdf.js can use a lot of memory</a> in at least some cases.  We need to investigate the known cases and improve things.</p>
<h4>#4: Dev tools</h4>
<p>While we&#8217;ve made great progress with memory profiling tools that help Firefox developers, the situation is not nearly as good for web developers.  Google Chrome has heap profiling tools for web developers, and Firefox should too.  (The design space for heap profilers is quite large and so Firefox shouldn&#8217;t just copy Chrome&#8217;s tools.)  Alexandre Poirot has started work on a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=863228">promising prototype</a>, though there is a lot of work remaining before any such prototype can make it into a release.</p>
<h4>#3: B2G Nuwa</h4>
<p>Cervantes Yu and Thinker Li have been working on <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=771765">Nuwa</a>, which aims to give B2G a pre-initialized template process from which every subsequent process will be forked.  This might sound esoteric, but the important part is that it greatly increases the ability for B2G processes to share unchanging data.  In <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=771765#c29">one test run</a>, this increased the number of apps that could be run simultaneously from five to <em>nine</em>, which is obviously a big deal.  The downside is that getting it to work requires some extremely hairy fiddling with low-level code.  Fingers crossed it can be made to work reliably!</p>
<p>Beyond Nuwa, there is still plenty of other ways that B2G can have its memory consumption optimized, as you&#8217;d expect in an immature mobile OS.  Although I won&#8217;t list anything else in the big ticket items list, work will continue here, as per <a href="https://wiki.mozilla.org/Performance/MemShrink">MemShrink&#8217;s primary aim:</a> &#8220;MemShrink is a project that aims to reduce the memory consumption of Firefox (on desktop and mobile) and Firefox OS.&#8221;</p>
<h4>#2: Compacting Generational GC</h4>
<p>Generational GC will reduce fragmentation, reduce the working set size, and speed up collections.  Great progress has been made here &#8212; the enormous task of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=753203">exactly rooting</a> the JS engine and the browser is basically finished, helped along greatly by a static analysis implemented by Brian Hackett.  And Terrence Cole and others are well into converting the collector to be generational.  So we&#8217;re a lot closer than we were, but there is still some way to go.  So this item is steady at #2.</p>
<h4>#1: Better Foreground Tab Image Handling</h4>
<p>Firefox still uses much more memory than other browsers on image-heavy pages.  Fortunately, a great deal of progress has been made here.  Timothy Nikkel <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=689623">fixed things</a> so that memory usage when scrolling through image-heavy pages is greatly reduced.  However, this change caused some <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=845147">jank on pages with lots of small images</a>, so it&#8217;s currently disabled on the non-trunk branches.  Also, there is still a memory spike when <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=847223">memory-heavy pages are first loaded</a>, which needs to be fixed before this item can be considered done.  So this item remains at #1.</p>
<h4>Summary</h4>
<p>Three items from the old list (#3, #4, #5) have been ticked off.  Two items remain (#1, #2) &#8212; albeit with good progress having been made &#8212; and keep their positions on the list.  Three items have been added to the new list (#3, #4, #5).<br />
Let me know if I&#8217;ve omitted anything important!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/06/15/memshrinks-2nd-birthday/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MemShrink progress, week 103&#8211;104</title>
		<link>http://blog.mozilla.org/nnethercote/2013/06/12/memshrink-progress-week-103-104/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/06/12/memshrink-progress-week-103-104/#comments</comments>
		<pubDate>Wed, 12 Jun 2013 05:10:37 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Memory consumption]]></category>
		<category><![CDATA[MemShrink]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2614</guid>
		<description><![CDATA[I&#8217;m back from vacation.  Many thanks to Andrew McCreight for writing two MemShrink reports (here and here) while I was away, and to Justin Lebar for hosting them on his blog. Fixes areweslimyet.com proved its value again, identifying a 40 &#8230; <a href="http://blog.mozilla.org/nnethercote/2013/06/12/memshrink-progress-week-103-104/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m back from vacation.  Many thanks to Andrew McCreight for writing two MemShrink reports (<a href="http://jlebar.com/2013/5/8/MemShrink_process%2C_weeks_97-98.html">here</a> and <a href="http://jlebar.com/2013/5/8/MemShrink_process%2C_weeks_98-102.html">here</a>) while I was away, and to Justin Lebar for hosting them on <a href="http://jlebar.com/">his blog</a>.</p>
<h3>Fixes</h3>
<p>areweslimyet.com proved its value again, identifying <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=878062">a 40 MiB regression relating to layer animations</a>.  Joe Drew fixed the problem quickly.  Thanks, Joe!</p>
<p>Ben Turner <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=873356">changed the GC heuristics for web workers on B2G so that less garbage is allowed to accumulate</a>.  This was a MemShrink:P1.</p>
<p>Bas Schouten <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=829954">fixed a gfx top-crasher</a> that was caused by inappropriate handling of an out-of-memory condition.  This was also a MemShrink:P1.</p>
<p>Randell Jesup <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=872978">fixed a leak in WebRTC code</a>.</p>
<h3>Changes to these progress reports</h3>
<p>I&#8217;ve written over sixty MemShrink progress reports in the past two years.  When I started writing them, I had two major goals.  First, to counter the notion that nobody at Mozilla cares about memory consumption &#8212; this was a common comment on tech blogs two years ago.  Second, to keep interested people informed of MemShrink progress.</p>
<p>At this point, I think the first goal has been comprehensively addressed.  (More due to the  fact that we actually have improved Firefox&#8217;s memory consumption than because I wrote a bunch of blog posts!)  As a result, I feel like the value of these posts has diminished.  I&#8217;m also tired of writing them;  long-time readers may have noticed that they are much terser than they used to be.</p>
<p>Therefore, going forward, I&#8217;m only going to post one report every four weeks.  (The MemShrink team will still meet every two weeks, however.)  I&#8217;ll also be more selective about what I write about &#8212; I&#8217;ll focus on the big improvements, and I won&#8217;t list every little leak that has been fixed, though I might post links to Bugzilla searches that list those fixes. Finally, I won&#8217;t bother recording the MemShrink bug counts.  (In fact, I&#8217;ve started that today.)  At this point it&#8217;s pretty clear that the P1 list hovers between 15 and 20 most of the time, and the P2 and P3 lists grow endlessly.</p>
<p>Apologies to anyone disappointed by this, but rest easy that it will give me more time to work on actual improvements to Firefox <img src='http://blog.mozilla.org/nnethercote/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/06/12/memshrink-progress-week-103-104/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>On vacation until June 3rd</title>
		<link>http://blog.mozilla.org/nnethercote/2013/04/26/on-vacation-until-june-3rd/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/04/26/on-vacation-until-june-3rd/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 06:48:27 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2610</guid>
		<description><![CDATA[I&#8217;m about to go on vacation.  I won&#8217;t be back until June 3rd, and I will be checking email sporadically at best. I look forward to a mountain of bugmail when I return.]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m about to go on vacation.  I won&#8217;t be back until June 3rd, and I will be checking email sporadically at best.</p>
<p>I look forward to a mountain of bugmail when I return.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/04/26/on-vacation-until-june-3rd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Recent about:memory improvements</title>
		<link>http://blog.mozilla.org/nnethercote/2013/04/26/recent-aboutmemory-improvements/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/04/26/recent-aboutmemory-improvements/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 06:12:40 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[about:memory]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[MemShrink]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2602</guid>
		<description><![CDATA[The landing of patches from two recent bugs has substantially changed the look of about:memory.  When you load the page all see now is the following. Measurements aren&#8217;t taken away;  you have to click on the &#8220;Measure&#8221; button for that &#8230; <a href="http://blog.mozilla.org/nnethercote/2013/04/26/recent-aboutmemory-improvements/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The landing of patches from two <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=856917">recent</a> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=857382">bugs</a> has substantially changed the look of about:memory.  When you load the page all see now is the following.</p>
<p><a href="http://blog.mozilla.org/nnethercote/files/2013/04/am.png"><img class="alignnone size-full wp-image-2603" alt="about:memory screenshot" src="http://blog.mozilla.org/nnethercote/files/2013/04/am.png" width="1007" height="197" /></a></p>
<p>Measurements aren&#8217;t taken away;  you have to click on the &#8220;Measure&#8221; button for that to happen.  Also, adding ?verbose to the URL no longer has an effect.  If you want verbose output, you need to click on the &#8220;verbose&#8221; checkbox.</p>
<p>The motivation for this change was that about:memory&#8217;s functionality has expanded greatly over the past two years, and cramming more functionality into the existing UI was a bad idea.  There are numerous advantages to the new UI.</p>
<ul>
<li>No need to control behaviour via the URL, which is admittedly an odd way to do it.</li>
<li>You can switch between verbose and non-verbose modes without having to reload the page.</li>
<li>All the buttons are at the top of the page instead of the bottom, so you don&#8217;t have to scroll down.</li>
<li>You can trigger a GC/CC/minimize memory usage event without having do a memory measurement.</li>
<li>When you save reports to file, it&#8217;s clearer that a new measurement will be taken, rather than saving any measurements that are currently displayed on the screen.</li>
<li>The buttons are grouped by function, which makes them easier to understand.</li>
</ul>
<p>There&#8217;s also the &#8220;Load and diff&#8230;&#8221; button, which lets you easily find the difference between two saved memory report files.  Here&#8217;s some example output taken after closing a tab containing a Google search result.</p>
<p><a href="http://blog.mozilla.org/nnethercote/files/2013/04/diff.png"><img class="alignnone size-full wp-image-2604" alt="about:memory diff output" src="http://blog.mozilla.org/nnethercote/files/2013/04/diff.png" width="849" height="235" /></a></p>
<p>You can see that all the measurements are negative.  The [-] markers on leaf nodes in the tree indicate that they are present in the first file but not in the second file.  Corresponding [+] markers are used for measurements present in the second file but not the first.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/04/26/recent-aboutmemory-improvements/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>MemShrink progress, week 95–96</title>
		<link>http://blog.mozilla.org/nnethercote/2013/04/17/memshrink-progress-week-95-96/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/04/17/memshrink-progress-week-95-96/#comments</comments>
		<pubDate>Wed, 17 Apr 2013 05:55:01 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[about:memory]]></category>
		<category><![CDATA[B2G]]></category>
		<category><![CDATA[Memory consumption]]></category>
		<category><![CDATA[MemShrink]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2596</guid>
		<description><![CDATA[B2G Fixes Kyle Huey made image.src='' discard the image immediately even if the image is not in the document.  This provides a way for image memory to be discarded immediately, which is important for some B2G apps such as the &#8230; <a href="http://blog.mozilla.org/nnethercote/2013/04/17/memshrink-progress-week-95-96/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h3>B2G Fixes</h3>
<p>Kyle Huey <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=854799">made <code>image.src=''</code> discard the image immediately even if the image is not in the document</a>.  This provides a way for image memory to be discarded immediately, which is important for some B2G apps such as the Gallery app.  This was a MemShrink:P1 bug.</p>
<p>Justin Lebar <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=857653">fixed a bad leak in AudioChannelAgent</a>.</p>
<p>Mike Habicher <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=860395">fixed an image-related leak</a> that was manifesting on B2G.</p>
<h3>Other Fixes</h3>
<p>I <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=848560">exposed the existing JSON memory report dumping functionality in about:memory</a>.  As a result, <a title="Permalink to Gzipped JSON is now the preferred format for attaching memory report data to bugs" href="https://blog.mozilla.org/nnethercote/2013/04/10/gzipped-json-is-now-the-preferred-format-for-attaching-memory-report-data-to-bugs/" rel="bookmark">gzipped JSON is now the preferred format for attaching memory report data to bugs</a>.  This was a MemShrink:P1 bug.</p>
<p>Honza Bambas <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=600307">overhauled the DOM storage code</a>.  Apparently this might reduce memory consumption, but I fully admit to not knowing the details.</p>
<p>Nicolas Silva <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=856080">fixed a leak in layers code relating to OMTC</a>.</p>
<p>I <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=859657">removed the MEMORY_EXPLICIT telemetry measurement</a>.  I didn&#8217;t want to do this, but it&#8217;s been causing hangs for some users, and those hangs are hard to avoid due to the complexity of reporting memory consumption from web workers.  Furthermore, in practice the measurement was sufficiently noisy that we&#8217;ve never gotten anything useful from it.</p>
<h3>Help Needed</h3>
<p>Mozilla code uses a mixture of fallible and infallible allocations.  In theory, any allocation that could allocate a large amount of memory (e.g. a few hundred KiB or more) should use a fallible allocator.  We&#8217;ve seen recently some cases where large allocations were being made infallibly, which led to OOM crashes.  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=862592">Bug 862592</a> proposes adding an assertion to the infallible allocators that the request size isn&#8217;t too large.  This is an easy bug to get started with, if anyone is interested.  Details are in the bug.</p>
<h3>Bug Counts</h3>
<p>Here are the current bug counts.</p>
<ul>
<li>P1: 15 (-4/+4)</li>
<li>P2: 145 (-0/+7)</li>
<li>P3: 131 (-2/+4)</li>
<li>Unprioritized: 5 (-1/+5)</li>
</ul>
<h3>Interregnum</h3>
<p>I will be on vacation during May.  As a result, there will be no MemShrink reports for the next three fortnights.  (Although I&#8217;ll be away for just over four weeks, that period covers three MemShrink meetings.)  I&#8217;ll be back with the next report on June 11.  See you then!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/04/17/memshrink-progress-week-95-96/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Gzipped JSON is now the preferred format for attaching memory report data to bugs</title>
		<link>http://blog.mozilla.org/nnethercote/2013/04/10/gzipped-json-is-now-the-preferred-format-for-attaching-memory-report-data-to-bugs/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/04/10/gzipped-json-is-now-the-preferred-format-for-attaching-memory-report-data-to-bugs/#comments</comments>
		<pubDate>Wed, 10 Apr 2013 00:17:07 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[about:memory]]></category>
		<category><![CDATA[MemShrink]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2579</guid>
		<description><![CDATA[Old: Text about:memory is our main memory profiling tool.  You can copy and paste the memory reports shown by about:memory and they will reproduce nicely &#8212; so long as the displaying text is a fixed-width font &#8212; as the following &#8230; <a href="http://blog.mozilla.org/nnethercote/2013/04/10/gzipped-json-is-now-the-preferred-format-for-attaching-memory-report-data-to-bugs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h3>Old: Text</h3>
<p>about:memory is our main memory profiling tool.  You can copy and paste the memory reports shown by about:memory and they will reproduce nicely &#8212; so long as the displaying text is a fixed-width font &#8212; as the following example shows.</p>
<pre>Main Process

Explicit Allocations
536.22 MB (100.0%) -- explicit
├──217.45 MB (40.55%) -- window-objects
│  ├───91.55 MB (17.07%) -- top(https://mail.google.com/mail/u/0/#label/A-moz%2Fbugz/13d41da77907a707, id=16)/active
│  │   ├──61.18 MB (11.41%) -- window(https://mail.google.com/_/mail-static/_/js/main/m_i,t/rt=h/ver=sobKNxkH_hk.en./sv=1/am=!rsy2VLKefbT1RPF-0_JbQoI4nDfwRxdk-CbEiLu_TGxDGzw05OfUOUODZR_O2flp0CcdPg/d=1)
│  │   │  ├──56.29 MB (10.50%) -- js
│  │   │  │  ├──56.11 MB (10.46%) -- compartment(https://mail.google.com/_/mail-static/_/js/main/m_i,t/rt=h/ver=sobKNxkH_hk.en./sv=1/am=!rsy2VLKefbT1RPF-0_JbQoI4nDfwRxdk-CbEiLu_TGxDGzw05OfUOUODZR_O2flp0CcdPg/d=1)
│  │   │  │  │  ├──35.23 MB (06.57%) -- gc-heap
│  │   │  │  │  │  ├──18.17 MB (03.39%) -- objects
│  │   │  │  │  │  │  ├───9.88 MB (01.84%) ── dense-array
│  │   │  │  │  │  │  ├───6.08 MB (01.13%) ── ordinary
│  │   │  │  │  │  │  └───2.21 MB (00.41%) ++ (2 tiny)
│  │   │  │  │  │  ├──10.71 MB (02.00%) ++ (6 tiny)
│  │   │  │  │  │  └───6.35 MB (01.18%) ── unused-gc-things
│  │   │  │  │  ├──12.01 MB (02.24%) ++ (7 tiny)
│  │   │  │  │  └───8.86 MB (01.65%) ++ objects-extra
│  │   │  │  └───0.19 MB (00.04%) ++ compartment(https://mail.google.com/_/mail-static/_/js/main/m_i,t/rt=h/ver=sobKNxkH_hk.en./sv=1/am=!rsy2VLKefbT1RPF-0_JbQoI4nDfwRxdk-CbEiLu_TGxDGzw05OfUOUODZR_O2flp0CcdPg/d=1, about:blank)
│  │   │  └───4.89 MB (00.91%) ++ (4 tiny)</pre>
<p>Accordingly, until now the preferred way of reporting about:memory&#8217;s data in bug reports has been to include a copy of the entire contents of about:memory?verbose.</p>
<p>This worked well when about:memory contained a few dozen lines.  But the level of detail in the underlying memory reporters has increased greatly since then.  This is a good thing &#8212; more data is helpful &#8212; but it means that a full about:memory?verbose is now typically thousands of lines.  When viewing the data directly in about:memory?verbose this isn&#8217;t a problem, because you can easily collapse and expand sub-trees to focus on the interesting parts.  However, when reading pasted data as text, it&#8217;s overwhelming, even for experts.</p>
<h3>New: Gzipped JSON</h3>
<p>With the landing of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=848560">bug 848560</a>, about:memory can now import and export memory reports as gzipped JSON.  Use the &#8220;Write reports to a file&#8221; and &#8220;Read reports from a file&#8221; buttons at the bottom of about:memory.  (Note: the UI will <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=856917">likely change soon</a>, but not substantively.)</p>
<p>(The JSON schema is documented in a comment near the top of xpcom/base/nsIMemoryInfoDumper.idl, for those who are interested.)</p>
<p>This is now the preferred format for attaching memory report data to bug reports.  It has two important advantages over text.</p>
<ul>
<li>When you load one of these files into about:memory, you can do the aforementioned collapsing and expanding of sub-trees.</li>
<li>If you have two of these files, you can diff them using toolkit/components/aboutmemory/tools/diff-memory-reports.js.  (For the moment you&#8217;ll have to ungzip both files first, which is stupid.  Hopefully this&#8217;ll be <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=860105">fixed soon</a>.)</li>
</ul>
<p>The ability to compute memory report diffs will be extremely useful for diagnosing cases where Firefox&#8217;s memory consumption increases unexpectedly.  (There are already <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=849743">two</a> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=857806">bugs</a> that are waiting on this feature for a better diagnosis.)</p>
<p>There is a bug open to implement a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=859603">&#8220;Load reports from URL&#8221;</a> feature in about:memory, which will make the viewing memory reports attached to bugs even easier.  It&#8217;s currently unassigned;  please email me or comment in the bug if you are interested in implementing it.</p>
<p>Finally, although the gzipped JSON format is now the preferred format for transferring the full memory report data, copy and paste is still useful for communicating snippets of about:memory&#8217;s contents.  Support for it won&#8217;t be disappearing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/04/10/gzipped-json-is-now-the-preferred-format-for-attaching-memory-report-data-to-bugs/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mozilla Research is on a roll</title>
		<link>http://blog.mozilla.org/nnethercote/2013/04/04/mozilla-research-is-on-a-roll/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/04/04/mozilla-research-is-on-a-roll/#comments</comments>
		<pubDate>Thu, 04 Apr 2013 10:32:19 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2564</guid>
		<description><![CDATA[I was struck by the following slide from Brendan&#8217;s Mozilla-at-15 post. Hot damn, those are some impressive projects.]]></description>
				<content:encoded><![CDATA[<p>I was struck by the following slide from Brendan&#8217;s <a href="https://brendaneich.com/2013/04/mozilla-at-15-memories-and-thoughts-on-mozilla-research/">Mozilla-at-15 post</a>.</p>
<p><a href="http://blog.mozilla.org/nnethercote/files/2013/04/mozilla-research.png"><img class="alignnone size-full wp-image-2566" alt="Current Mozilla Research projects" src="http://blog.mozilla.org/nnethercote/files/2013/04/mozilla-research.png" width="1008" height="534" /></a></p>
<p>Hot damn, those are some impressive projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/04/04/mozilla-research-is-on-a-roll/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MemShrink progress, week 93&#8211;94</title>
		<link>http://blog.mozilla.org/nnethercote/2013/04/03/memshrink-progress-week-93-94/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/04/03/memshrink-progress-week-93-94/#comments</comments>
		<pubDate>Wed, 03 Apr 2013 04:49:57 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[about:memory]]></category>
		<category><![CDATA[Fennec]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Memory consumption]]></category>
		<category><![CDATA[MemShrink]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2554</guid>
		<description><![CDATA[After lots of activity in the previous month, the past two weeks have been fairly quiet for MemShrink. AWSY areweslimyet.com has been proving its worth. Jonathan Kew reduced the amount of memory taken by fonts on Fennec at start-up, which &#8230; <a href="http://blog.mozilla.org/nnethercote/2013/04/03/memshrink-progress-week-93-94/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>After lots of activity in the previous month, the past two weeks have been fairly quiet for MemShrink.</p>
<h3>AWSY</h3>
<p>areweslimyet.com has been proving its worth.</p>
<p>Jonathan Kew <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=844669">reduced the amount of memory taken by fonts on Fennec at start-up</a>, which was detected by AWSY/mobile.  Jonathan also <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=846832">reverted a change that AWSY detected as increasing Fennec memory consumption</a>, and filed a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=847344">follow-up</a> to investigate further.</p>
<p>Joe Drew <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=853390">fixed a bad regression on AWSY relating to image decoding</a>.  It&#8217;s not clear to me if this was a genuine regression that users would have seen, or if it was an artifact of the way AWSY does its measurements.  Either way, it&#8217;s good that it was fixed, and props to Joe for doing it so quickly.</p>
<p>Finally, we closed <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=833518">bug 833518</a>, which was for an AWSY regression caused by the new DOM bindings.  This was previously improved by an Aurora-only hack, but enough cases have been translated to the new bindings that we&#8217;re naturally down almost to where we were.</p>
<h3>Miscellaneous</h3>
<p>The mobile team abandoned their <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=792131">goal of making Fennec work on phones with only 256 MiB of memory</a>.  The rationale is that Android phones with only 256 MiB of RAM are uncommon, whereas low-end phones that meet the current minimum of 384 MiB are much more common.  The mobile team will of course continue to look for ways to improve memory consumption in order to make life for users with 384 MiB phones.</p>
<p>I <a href="https://bugzilla.mozilla.org//show_bug.cgi?id=851421">modified the JS engine so that it doesn&#8217;t emit bytecode for asm.js functions in the normal case</a>.  This reduced the memory consumption of the Unreal 3 demo used at GDC by about 100 MiB.  I also <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=854763">added a memory reporter for array buffers used by asm.js</a>, which are often quite large and weren&#8217;t being measured on 64-bit platforms.</p>
<p>Alexandre Poirot <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=839280">fixed a leak relating to dev tools</a>.</p>
<p>Randell Jesup <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=848946">fixed a small leak in WebRTC</a>.</p>
<h3>Help Needed</h3>
<p>I&#8217;m working on <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=848560">adding a button to about:memory trigger the dumping of memory reporter data to file</a>.  I have a patch awaiting review, but I&#8217;m getting a test failure on Windows.  The test saves gzipped memory reports to file, and then immediately loads that saved file (and uncompresses it) and checks the data looks as expected.  This works fine on Mac and Linux, but on Windows I&#8217;m sometimes getting incomplete data in the load step.  The file is quite short (just 253 bytes compressed, and 620 bytes uncompressed) and the truncation point varies between runs;  in the most severe occurrence only 9 bytes of uncompressed data were loaded, though the cut-off point seems to vary randomly.</p>
<p>I suspect there&#8217;s a file synchronization problem between the save and the load, even though gzclose() is called on the save file before the loading occurs.  If anyone has ideas about what the problem might be, I&#8217;d love to hear them.</p>
<p><strong>Update: Nils Maier and an anonymous commenter pointed out the problem &#8212; I was using &#8220;r&#8221; instead of &#8220;rb&#8221; for the file mode.  On Windows, this causes <a href="http://stackoverflow.com/questions/11141422/why-use-fopen-mode-b-stdio-h-when-output-can-be-non-ascii-regardless">mangling of EOL chars</a>.</strong></p>
<p>Also, we&#8217;re seeing some <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=855151">strange behaviour on Mac OS X where memory managed by jemalloc doesn&#8217;t appear to be released back to the OS as it should</a>.  This is both alarming and hard to understand, which is not a good combination.</p>
<h3>Good First Bugs</h3>
<p>I have two easy bugs assigned to me that I probably won&#8217;t get around to for some time.  Both of them would be good first (or second, or third&#8230;) bugs.</p>
<ul>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=857382">Bug 857382</a> is about making about:memory handle memory report diffs more elegantly.</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=798914">Bug 798914</a> is just a minor code clean-up.  Nothing too exciting, but first bugs often aren&#8217;t!</li>
</ul>
<p>Please email or comment in one of the bugs if you are interested in helping.</p>
<h3>Bug Counts</h3>
<p>Here are the current bug counts.</p>
<ul>
<li>P1: 15 (-0/+2)</li>
<li>P2: 138 (-4/+8)</li>
<li>P3: 129 (-2/+7)</li>
<li>Unprioritized: 1 (-3/+0)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/04/03/memshrink-progress-week-93-94/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>An interesting use of the try server</title>
		<link>http://blog.mozilla.org/nnethercote/2013/03/27/an-interesting-use-of-the-try-server/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/03/27/an-interesting-use-of-the-try-server/#comments</comments>
		<pubDate>Tue, 26 Mar 2013 23:00:58 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[Try Server]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2545</guid>
		<description><![CDATA[I have a patch that&#8217;s ready to land.  I wanted to ensure that it compiles on all platforms.  I also wanted to ensure that it passes all tests, but I felt that running all the tests on one of the &#8230; <a href="http://blog.mozilla.org/nnethercote/2013/03/27/an-interesting-use-of-the-try-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I have a patch that&#8217;s ready to land.  I wanted to ensure that it compiles on all platforms.  I also wanted to ensure that it passes all tests, but I felt that running all the tests on one of the tier 1 platforms was enough.</p>
<p>There&#8217;s no way to specify this combination in a single try server push, but I realized I could do it with two separate pushes.  <a href="http://trychooser.pub.build.mozilla.org/">TryChooser</a> told me that Linux64 was the least-loaded platform, so I did a <a href="https://tbpl.mozilla.org/?tree=Try&amp;rev=f18585c1cb46">try run</a> with all the tests on that platform:</p>
<pre>try: -b do -p linux64 -u all -t none</pre>
<p>And then I did a <a href="https://tbpl.mozilla.org/?tree=Try&amp;rev=ab8a246852c1">try run</a> that did builds (but no tests) on all platforms except Linux64:</p>
<pre>try: -b do -p linux,macosx64,win32,android,android-armv6,android-noion,ics_armv7a_gecko,panda,otoro,unagi -u none -t none</pre>
<p>Interesting.  I wonder if this is a combination that other people have considered.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/03/27/an-interesting-use-of-the-try-server/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MemShrink progress, week 91&#8211;92</title>
		<link>http://blog.mozilla.org/nnethercote/2013/03/20/memshrink-progress-week-91-92/</link>
		<comments>http://blog.mozilla.org/nnethercote/2013/03/20/memshrink-progress-week-91-92/#comments</comments>
		<pubDate>Wed, 20 Mar 2013 05:19:29 +0000</pubDate>
		<dc:creator>Nicholas Nethercote</dc:creator>
				<category><![CDATA[B2G]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Memory consumption]]></category>
		<category><![CDATA[MemShrink]]></category>

		<guid isPermaLink="false">http://blog.mozilla.org/nnethercote/?p=2534</guid>
		<description><![CDATA[Bill McCloskey landed zones, a.k.a. compartment groups.  This mitigates the overhead of each compartment by allowing all compartments within a zone to share arenas and strings.  Roughly speaking, each tab gets its own zone, and there&#8217;s a system zone for &#8230; <a href="http://blog.mozilla.org/nnethercote/2013/03/20/memshrink-progress-week-91-92/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Bill McCloskey landed <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=759585">zones</a>, a.k.a. compartment groups.  This mitigates the overhead of each compartment by allowing all compartments within a zone to share arenas and strings.  Roughly speaking, each tab gets its own zone, and there&#8217;s a system zone for Firefox&#8217;s internal use.  This was a MemShrink:P1 bug.</p>
<p>The following graph from areweslimyet.com shows the impact of zones &#8212; about 5/6 of the way along the graph there&#8217;s a distinct drop, most noticeable in the dark blue line.  The light green line (settled start-up) showed a ~6 MiB drop, which is ~10%.  Note that the fraction of JS memory in areweslimyet.com is less than that in typical sites, so the drop in the higher lines is smaller than the improvements normal users should see.</p>
<p><a href="http://blog.mozilla.org/nnethercote/files/2013/03/awsy.png"><img class="alignnone size-full wp-image-2535" alt="areweslimyet.com graph showing improvements due to zones" src="http://blog.mozilla.org/nnethercote/files/2013/03/awsy.png" width="1289" height="772" /></a></p>
<p>Avi Halachmi <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=837542">fixed a problem where badly managed gradients could cause spikes of 10s of MiBs when tab animations occurred</a>.  This was a MemShrink:P1 bug.  The fix has been backported to Aurora.</p>
<p>Jed Parsons <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=839500">fixed excessive memory consumption by Persona after visiting the B2G marketplace</a>.  At least, I think that&#8217;s what happened;  I won&#8217;t pretend to genuinely understand what went on in that bug.  This was a MemShrink:P1 bug.</p>
<p>Fabrice Desré <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=848615">fixed a bad B2G leak relating to error messages</a>.  This bug was fixed before it was triaged in a MemShrink meeting, but it probably would have been a MemShrink:P1 because it could cause the phone to OOM after a few hours.</p>
<p>I <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=847248">removed all uses of nsFixedSizeAllocator</a>.  This was only a small memory consumption win (a few 10s of KiBs) but it cut several hundred lines of code, and removed another low-quality custom allocator (and <a href="http://en.wikipedia.org/wiki/Attractive_nuisance_doctrine">attractive nuisance</a>) from the codebase.</p>
<p>I added a &#8220;js-main-runtime-temporary-peak&#8221; memory reporter, which measures the peak size of the main JSRuntime&#8217;s &#8220;temporary&#8221; pool, which mostly holds parse nodes.  These are short-lived but they can be quite large &#8212; 10s of MiBs in normal browsing, and we&#8217;ve seen it exceed 1.5 GiB on large asm.js examples.  Relatedly, I <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=747831">reduced the size of parse nodes</a> by 12.5% on 64-bit platforms, and 16.7% on 32-bit platforms.</p>
<h3>Interesting Open Bugs</h3>
<p>Sometimes, especially on B2G, we have excessive memory consumption due to JS strings.  It would be useful to be able to dump the contents of all the strings in memory, to look for ones that shouldn&#8217;t be there.  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=852010">Bug 852010</a> has been filed for this.  It shouldn&#8217;t be too hard, as it would fit in with the existing JSON memory report dumping infrastructure.  This is currently blocking <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=850893">bug 850893</a>, a B2G MemShrink:P1 bug.  Please comment in the bug or contact me if you want to get involved.</p>
<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=846616">Bug 846616</a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=850545">bug 850545</a> both are about high &#8220;heap-unclassified&#8221; values.  Reducing &#8220;heap-unclassified&#8221; is getting very difficult, because the memory is often allocated in ways we can&#8217;t measure by third-party code such as Cairo and graphics drivers.  I suppose in the Cairo case we could put effort into adding some memory profiling infrastructure and try to get it upstreamed, but the driver situation seems pretty hopeless.</p>
<h3>Bug Status</h3>
<p>Here are the current bug counts.</p>
<ul>
<li>P1: 13 (-3/+4)</li>
<li>P2: 134 (-2/+8)</li>
<li>P3: 124 (-4/+6)</li>
<li>Unprioritized: 4 (-6/+4)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.mozilla.org/nnethercote/2013/03/20/memshrink-progress-week-91-92/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>
