Categories
Australia B2G

Firefox OS phones on sale in Australia

Firefox OS phones are now on sale in Australia! You can buy a ZTE Open C with Firefox OS 1.3 installed for $99 (AUD) at JB Hi-Fi. (For non-Australian readers: JB Hi-Fi is probably the biggest electronics and home entertainment retailer in Australia.)

Australia’s not the ideal market for the current versions of Firefox OS, being aΒ  country where a large fraction of people already use high-end phones. But it’s nice that they’re easily available πŸ™‚

Categories
B2G

Poor battery life on the Flame device?

The new Firefox OS reference phone is called the Flame. I have one that I’m using as my day-to-day phone, and as soon as I got it I found that the battery life was terrible — I use my phone very lightly, but the battery was draining in only 24 hours or so.

It turns out this was because a kernel daemon called ksmd (kernel samepage merging daemon) was constantly running and using about 3–7% of CPU. I detected this by running the following command which prints CPU usage stats for all running processes every five seconds.

adb shell top -m 5

ksmd doesn’t seem very useful for a device such as the Flame, and Alexandre Lissy kindly built me a new kernel with it disabled, which improved my battery life by at least 3x. Details are in the relevant bug.

It seems that plenty of other Flame users are not having problems with ksmd, but if your Flame’s battery life is poor it would be worth checking if this is the cause.

Categories
B2G Fennec Firefox Garbage Collection Memory consumption MemShrink pdf.js

MemShrink’s 3rd birthday

June 14, 2014 was the third anniversary of the first MemShrink meeting. MemShrink is a mature effort at this point, and many of the problems that motivated its creation have been fixed. Nonetheless, there are still some areas for improvement. So, as I did at this time last year, I’ll take the opportunity to update the “big ticket items” list.

The Old Big Ticket Items List

#5: pdf.js

pdf.js is the PDF viewer that now ships by default in Firefox. I greatly reduced its memory usage in two rounds, first in February, and again in June. The first round of improvements were released in Firefox 29, and the second round is due to be released in Firefox 33, which should be out in mid-October.

pdf.js will still use more memory than native PDF viewers, but the situation has improved enough that it can be removed from this list.

#4: Dev tools

See below.

#3: B2G Nuwa

Cervantes Yu, Thinker Li, and others succeeded in landing Nuwa, an impressive technical achievement that increased the amount of memory sharing between different processes on Firefox OS. This allows many more apps to run at once. I think this is present in Firefox OS 1.3 and later.

#2: Compacting Generational GC

See below.

#1: Better Foreground Tab Image Handling

Timothy Nikkel completely fixed the massive spikes in decoded image data that we used to get on image-heavy pages. This was a fantastic improvement that shipped in Firefox 26.

The New Big Ticket Items List

In a break from tradition, I will present the items in alphabetical order, rather than ranking them. This reflects the fact that I don’t have a clear opinion on the relevant importance of these different items. (I view this as a good thing, because it means that I feel there aren’t any hair-on-fire problems.)

Better regression detection

areweslimyet.com (a.k.a. AWSY) is our best tool for detecting memory usage regressions. It currently tracks Firefox and Firefox for Android, and there are plans to integrate Firefox OS.

Unfortunately, although AWSY has been successful at detecting large regressions, leading to them being fixed, its measurements are noisy enough that detecting smaller regressions is difficult. As a result, the general trend of the graphs has been upward. I do not think this is as bad as it looks at first glance, because Firefox’s behaviour in the worst cases — which matter more than the average case — is much better than it used to be. Nonetheless, improved sensitivity here would be an excellent thing, and Eric Rahm is actively working on this.

Developer tools

Developer-oriented memory profiling tools are under active development by Nick Fitzgerald, Jim Blandy, and others. A lot of the necessary profiling infrastructure is in place, and this seems to be progressing well, though I don’t know when it’s expected to be finished.

By the way, if you haven’t tried Firefox’s dev tools recently, you should! They have improved an incredible amount in the past year or so.

GC Arena Fragmentation

Generational GC landed a few months ago. I had been hoping that this would help reduce GC fragmentation, but the effect was small. It looks like compacting GC is what’s needed to make a big difference here, though some smaller tweaks may help things a little.

Tarako

Tarako is the codename for the “$25 phone” running Firefox OS that will ship in India and other countries later this year. It has a paltry 128 MiB of RAM, so memory usage is critical. Since the hardware first became available to Mozilla employees at the start of the year, Tarako has improved from “almost unusable” to “not bad”. But apps still close due to OOMs fairly frequently, especially when a user does something that involves two apps working together in some way.

There is no single change that will decisively fix this problem for Tarako;Β  further improvements will require an ongoing grind of work from many engineers. Improvements made for Tarako are also likely to benefit higher-end Firefox OS devices as well.

Windows OOM crashes

The number of out-of-memory (OOM) crashes that occur on Windows is relatively high. A sizeable fraction of these appear to be 32-bit virtual OOM crashes, caused by running out of address space.

Things that will mitigate this include modifications to jemalloc and the JS allocator, as well as Electrolysis. And some additionalΒ data and analysis may help us understand the problem better.

The ultimate solution, for users on 64-bit versions of Windows, is 64-bit Firefox builds for Windows, though it’ll be a while before those builds are in good enough shape to ship to regular users.

Summary

Three items from the old list (pdf.js, Nuwa, image handling) have been ticked off.Β  Two items remain (devtools, GC fragmentation), the latter in altered form, and both are a lot closer to completion than they were. Three new items (regression detection, Tarako, and Windows OOMs) have been added.

Let me know if I’ve omitted anything important!

Categories
about:memory B2G Memory consumption MemShrink

Nuwa has landed

A big milestone for Firefox OS was reached this week: after several bounces spread over several weeks, Nuwa finally landed and stuck.

Nuwa is a special Firefox OS process from which all other app processes are forked. (The name “Nuwa” comes from the Chinese creation goddess.) It allows lots of unchanging data (such as low-level Gecko things like XPCOM structures) to be shared among app processes, thanks to Linux’s copy-on-write forking semantics. This greatly increases the number of app processes that can be run concurrently, which is why it was the #3 item on the MemShrink “big ticket items” list.

One downside of this increased sharing is that it renders about:memory’s measurements less accurate than before, because about:memory does not know about the sharing, and so will over-report shared memory. Unfortunately, this is very difficult to fix, because about:memory’s reports are generated entirely within Firefox, whereas the sharing information is only available at the OS level. Something to be aware of.

Thanks to Cervantes Yu (Nuwa’s primary author), along with those who helped, including Thinker Li, Fabrice DesrΓ©, and Kyle Huey.

Categories
about:memory B2G Memory consumption MemShrink

System-wide memory measurement for Firefox OS

Have you ever wondered exactly how all the physical memory in a Firefox OS device is used?Β Β  Wonder no more.Β  I just landed a system-wide memory reporter which works on any Firefox product running on a Linux system.Β  This includes desktop Firefox builds on Linux, Firefox for Android, and Firefox OS.

This memory reporter is a bit different to the existing ones, which work entirely within Mozilla processes.Β  The new reporter provides measurements for the entire system, including every user-space process (Mozilla or non-Mozilla) that is running.Β  It’s aimed primarily at profiling Firefox OS devices, because we have full control over the code running on those devices, and so it’s there that a system-wide view is most useful.

Here is some example output from a GeeksPhone Keon.

System
Other Measurements 
397.24 MB (100.0%) -- mem
β”œβ”€β”€215.41 MB (54.23%) ── free
β”œβ”€β”€105.72 MB (26.61%) -- processes
β”‚  β”œβ”€β”€β”€57.59 MB (14.50%) -- process(/system/b2g/b2g, pid=709)
β”‚  β”‚   β”œβ”€β”€42.29 MB (10.65%) -- anonymous
β”‚  β”‚   β”‚  β”œβ”€β”€42.25 MB (10.63%) -- outside-brk
β”‚  β”‚   β”‚  β”‚  β”œβ”€β”€41.94 MB (10.56%) ── [rw-p] [69]
β”‚  β”‚   β”‚  β”‚  └───0.31 MB (00.08%) ++ (2 tiny)
β”‚  β”‚   β”‚  └───0.05 MB (00.01%) ── brk-heap/[rw-p]
β”‚  β”‚   β”œβ”€β”€13.03 MB (03.28%) -- shared-libraries
β”‚  β”‚   β”‚  β”œβ”€β”€β”€8.39 MB (02.11%) -- libxul.so
β”‚  β”‚   β”‚  β”‚   β”œβ”€β”€6.05 MB (01.52%) ── [r-xp]
β”‚  β”‚   β”‚  β”‚   └──2.34 MB (00.59%) ── [rw-p]
β”‚  β”‚   β”‚  └───4.64 MB (01.17%) ++ (69 tiny)
β”‚  β”‚   └───2.27 MB (00.57%) ++ (2 tiny)
β”‚  β”œβ”€β”€β”€21.73 MB (05.47%) -- process(/system/b2g/plugin-container, pid=756)
β”‚  β”‚   β”œβ”€β”€12.49 MB (03.14%) -- anonymous
β”‚  β”‚   β”‚  β”œβ”€β”€12.48 MB (03.14%) -- outside-brk
β”‚  β”‚   β”‚  β”‚  β”œβ”€β”€12.41 MB (03.12%) ── [rw-p] [30]
β”‚  β”‚   β”‚  β”‚  └───0.07 MB (00.02%) ++ (2 tiny)
β”‚  β”‚   β”‚  └───0.02 MB (00.00%) ── brk-heap/[rw-p]
β”‚  β”‚   β”œβ”€β”€β”€8.88 MB (02.23%) -- shared-libraries
β”‚  β”‚   β”‚   β”œβ”€β”€7.33 MB (01.85%) -- libxul.so
β”‚  β”‚   β”‚   β”‚  β”œβ”€β”€4.99 MB (01.26%) ── [r-xp]
β”‚  β”‚   β”‚   β”‚  └──2.34 MB (00.59%) ── [rw-p]
β”‚  β”‚   β”‚   └──1.54 MB (00.39%) ++ (50 tiny)
β”‚  β”‚   └───0.36 MB (00.09%) ++ (2 tiny)
β”‚  β”œβ”€β”€β”€14.08 MB (03.54%) -- process(/system/b2g/plugin-container, pid=836)
β”‚  β”‚   β”œβ”€β”€β”€7.53 MB (01.89%) -- shared-libraries
β”‚  β”‚   β”‚   β”œβ”€β”€6.02 MB (01.52%) ++ libxul.so
β”‚  β”‚   β”‚   └──1.51 MB (00.38%) ++ (47 tiny)
β”‚  β”‚   β”œβ”€β”€β”€6.24 MB (01.57%) -- anonymous
β”‚  β”‚   β”‚   β”œβ”€β”€6.23 MB (01.57%) -- outside-brk
β”‚  β”‚   β”‚   β”‚  β”œβ”€β”€6.23 MB (01.57%) ── [rw-p] [22]
β”‚  β”‚   β”‚   β”‚  └──0.00 MB (00.00%) ── [r--p]
β”‚  β”‚   β”‚   └──0.01 MB (00.00%) ── brk-heap/[rw-p]
β”‚  β”‚   └───0.31 MB (00.08%) ++ (2 tiny)
β”‚  └───12.32 MB (03.10%) ++ (23 tiny)
└───76.11 MB (19.16%) ── other

The data is obtained entirely from the operating system, specifically from /proc/meminfo and the /proc/<pid>/smaps files, which are files provided by the Linux kernel specifically for measuring memory consumption.

I wish that the mem entry at the top was the amount of physical memory available. Unfortunately there is no way to get that on a Linux system, and so it’s instead the MemTotal value from /proc/meminfo, which is “Total usable RAM (i.e. physical RAM minus a few reserved bits and the kernel binary code)”.Β  And if you’re wondering about the exact meaning of the other entries, as usual if you hover the cursor over an entry in about:memory you’ll get a tool-tip explaining what it means.

The measurements given for each process are the PSS (proportional set size) measurements.Β  These attribute any shared memory equally among all processes that share it, and so PSS is the only measurement that can be sensibly summed across processes (unlike “Size” or “RSS”, for example).

For each process there is a wealth of detail about static code and data.Β  (The above example only shows a tiny fraction of it, because a number of the sub-trees are collapsed.Β  If you were viewing it in about:memory, you could expand and collapse sub-trees to your heart’s content.)Β  Unfortunately, there is little information about anonymous mappings, which constitute much of the non-static memory consumption.Β  I have some patches that will add an extra level of detail there, distinguishing major regions such as the jemalloc heap, the JS GC heap, and JS JIT code.Β  For more detail than that, the existing per-process memory reports in about:memory can be consulted.Β  Unfortunately the new system-wide reporter cannot be sensibly combined with the existing per-process memory reporters because the latter are unaware of implicit sharing between processes.Β  (And note that the amount of implicit sharing is increased significantly by the new Nuwa process.)

Because this works with our existing memory reporting infrastructure, anyone already using the get_about_memory.py script with Firefox OS will automatically get these reports along with all the usual ones once they update their source code, and the system-wide reports can be loaded and viewed in about:memory as usual. On Firefox and Firefox for Android, you’ll need to set the memory.system_memory_reporter flag in about:config to enable it.

My hope is that this reporter will supplant most or all of the existing tools that are commonly used to understand system-wide memory consumption on Firefox OS devices, such as ps, top and procrank.Β  And there will certainly be other interesting, available OS-level measurements that are not currently obtained. For example, Jed Davis has plans to measure the pmem subsystem.Β  Please file a bug or email me if you have other suggestions for adding such measurements.

Categories
about:memory B2G Firefox Memory consumption MemShrink

MemShrink progress, week 109–112

There’s been a lot of focus on B2G memory consumption in the past four weeks.Β  Indeed, of the 38 MemShrink bugs fixed in that time, a clear majority of them relate in some way to B2G.

In particular, Justin Lebar, Kyle Huey and Andrew McCreight have done a ton of important work tracking down leaks in both Gecko and Gaia.Β  Many of these have been reported by B2G partner companies doing stress testing such as opening and closing apps 100s or 1000s of times over long period.Β  Some examples (including three MemShrink P1s) are here, here, here, here, here, here, here and here.Β  There are still some P1s remaining (e.g. here, here, here).Β  This work is painstaking and requires lots of futzing around with low-level tools such as the GC/CC logs, unfortunately.

Relatedly, Justin modified the JS memory reporter to report “notable” strings, which includes smallish strings that are duplicated many times, a case that has occurred on B2G a couple of times.Β  Justin also moved some of the “heap-*” reports that previously lived in about:memory’s “Other measurements” section into the “explicit” tree.Β  This makes “explicit” closer to “resident” a lot of the time, which is a useful property.

Finally, Luke Wagner greatly reduced the peak memory usage seen during parsing large asm.js examples.Β  For the Unreal demo, this reduced the peak from 881MB to 6MB, and reduced start-up time by 1.5 seconds!Β  Luke also slightly reduced the size of JSScript, which is one of the very common structures on the JS GC heap, thus reducing pressure on the GC heap, which is always a good thing.

 

Categories
B2G Firefox Memory consumption MemShrink

MemShrink’s 2nd Birthday

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’s first year.Β  Unsurprisingly, since then we’ve been picking fruit from higher in the tree, so the advances have been less dramatic.Β  But it’s been 11 months since I last update the “big ticket items” list, so I will take this opportunity to do so, providing a partial summary of the past year at the same time.

The Old Big Ticket Items List

#5: Better Script Handling

This had two parts.Β  The first part was the sharing of immutable parts of scripts, which Till Schneidereit implemented.Β  It can save multiple MiBs of memory, particular if you have numerous tabs open from the same website.

The second part is lazy bytecode generation, which Brian Hackett has implemented and landed, though it hasn’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’s memory consumption by 5% or more on common workloads!Β  That’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’ll have bad GC behaviour (e.g. pauses, or too much memory consumption) in cases where the GC heuristics aren’t optimal.

So the first part is done and the second is imminent, which is enough to cross this item off the list.Β  [Update:Β  Brian just enabled lazy bytecode on trunk!]

#4: Regain compartment-per-global losses

Bill McCloskey implemented zones, 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%.

Some more could still be done for this issue.Β  In particular, it’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’m happy to take this item off the list.

#3: Boot2Gecko

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 Operation Slim Fast.

So I will remove this particular item from the list, but memory optimizations for B2G are far from over, as we’ll see below.

#2: Compacting Generational GC

See below.

#1: Better Foreground Tab Image Handling

See below.

The New Big Ticket Items List

#5: pdf.js

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’s not as good for memory consumption, because pdf.js can use a lot of memory in at least some cases.Β  We need to investigate the known cases and improve things.

#4: Dev tools

While we’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’t just copy Chrome’s tools.)Β  Alexandre Poirot has started work on a promising prototype, though there is a lot of work remaining before any such prototype can make it into a release.

#3: B2G Nuwa

Cervantes Yu and Thinker Li have been working on Nuwa, 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 one test run, this increased the number of apps that could be run simultaneously from five to nine, 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!

Beyond Nuwa, there is still plenty of other ways that B2G can have its memory consumption optimized, as you’d expect in an immature mobile OS.Β  Although I won’t list anything else in the big ticket items list, work will continue here, as per MemShrink’s primary aim: “MemShrink is a project that aims to reduce the memory consumption of Firefox (on desktop and mobile) and Firefox OS.”

#2: Compacting Generational GC

Generational GC will reduce fragmentation, reduce the working set size, and speed up collections.Β  Great progress has been made here — the enormous task of exactly rooting 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’re a lot closer than we were, but there is still some way to go.Β  So this item is steady at #2.

#1: Better Foreground Tab Image Handling

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 fixed things so that memory usage when scrolling through image-heavy pages is greatly reduced.Β  However, this change caused some jank on pages with lots of small images, so it’s currently disabled on the non-trunk branches.Β  Also, there is still a memory spike whenΒ memory-heavy pages are first loaded, which needs to be fixed before this item can be considered done.Β  So this item remains at #1.

Summary

Three items from the old list (#3, #4, #5) have been ticked off.Β  Two items remain (#1, #2) — albeit with good progress having been made — and keep their positions on the list.Β  Three items have been added to the new list (#3, #4, #5).
Let me know if I’ve omitted anything important!

Categories
about:memory B2G Memory consumption MemShrink

MemShrink progress, week 95–96

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 Gallery app.Β  This was a MemShrink:P1 bug.

Justin Lebar fixed a bad leak in AudioChannelAgent.

Mike Habicher fixed an image-related leak that was manifesting on B2G.

Other Fixes

I exposed the existing JSON memory report dumping functionality in about:memory.Β  As a result, gzipped JSON is now the preferred format for attaching memory report data to bugs.Β  This was a MemShrink:P1 bug.

Honza Bambas overhauled the DOM storage code.Β  Apparently this might reduce memory consumption, but I fully admit to not knowing the details.

Nicolas Silva fixed a leak in layers code relating to OMTC.

I removed the MEMORY_EXPLICIT telemetry measurement.Β  I didn’t want to do this, but it’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’ve never gotten anything useful from it.

Help Needed

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’ve seen recently some cases where large allocations were being made infallibly, which led to OOM crashes.Β  Bug 862592 proposes adding an assertion to the infallible allocators that the request size isn’t too large.Β  This is an easy bug to get started with, if anyone is interested.Β  Details are in the bug.

Bug Counts

Here are the current bug counts.

  • P1: 15 (-4/+4)
  • P2: 145 (-0/+7)
  • P3: 131 (-2/+4)
  • Unprioritized: 5 (-1/+5)

Interregnum

I will be on vacation during May.Β  As a result, there will be no MemShrink reports for the next three fortnights.Β  (Although I’ll be away for just over four weeks, that period covers three MemShrink meetings.)Β  I’ll be back with the next report on June 11.Β  See you then!

Categories
B2G Firefox Memory consumption MemShrink

MemShrink progress, week 91–92

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’s a system zone for Firefox’s internal use.Β  This was a MemShrink:P1 bug.

The following graph from areweslimyet.com shows the impact of zones — about 5/6 of the way along the graph there’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.

areweslimyet.com graph showing improvements due to zones

Avi Halachmi fixed a problem where badly managed gradients could cause spikes of 10s of MiBs when tab animations occurred.Β  This was a MemShrink:P1 bug.Β  The fix has been backported to Aurora.

Jed Parsons fixed excessive memory consumption by Persona after visiting the B2G marketplace.Β  At least, I think that’s what happened;Β  I won’t pretend to genuinely understand what went on in that bug.Β  This was a MemShrink:P1 bug.

Fabrice DesrΓ© fixed a bad B2G leak relating to error messages.Β  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.

I removed all uses of nsFixedSizeAllocator.Β  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 attractive nuisance) from the codebase.

I added a “js-main-runtime-temporary-peak” memory reporter, which measures the peak size of the main JSRuntime’s “temporary” pool, which mostly holds parse nodes.Β  These are short-lived but they can be quite large — 10s of MiBs in normal browsing, and we’ve seen it exceed 1.5 GiB on large asm.js examples.Β  Relatedly, I reduced the size of parse nodes by 12.5% on 64-bit platforms, and 16.7% on 32-bit platforms.

Interesting Open Bugs

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’t be there.Β  Bug 852010 has been filed for this.Β  It shouldn’t be too hard, as it would fit in with the existing JSON memory report dumping infrastructure.Β  This is currently blocking bug 850893, a B2G MemShrink:P1 bug.Β  Please comment in the bug or contact me if you want to get involved.

Bug 846616 and bug 850545 both are about high “heap-unclassified” values.Β  Reducing “heap-unclassified” is getting very difficult, because the memory is often allocated in ways we can’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.

Bug Status

Here are the current bug counts.

  • P1: 13 (-3/+4)
  • P2: 134 (-2/+8)
  • P3: 124 (-4/+6)
  • Unprioritized: 4 (-6/+4)
Categories
B2G Firefox Memory consumption MemShrink

MemShrink progress, week 87–88

SpiderMonkey

Till Schneidereit implemented sharing of bytecode and related script data.Β  This can result in significant savings, especially if you have multiple tabs open from the same site.Β  For example, with 10 articles open from theage.com.au I saw an 11.6 MiB saving.Β  This was a MemShrink:P1, and its fix completes half of the “Better Script Handling” item from the MemShrink big ticket items list.

Terrence Cole fixed a bad regression that was causing multi-GiB memory spikes when using certain regular expressions.Β  He landed this fix on the Nightly, Aurora and Beta channels.

I reduced the overhead of small compartments a little.Β  This reduced the size of an unloaded tab from 222 KiB to 192 KiB on 64-bit platforms.

Jason Orendorff removed some source notes that are no longer required now that SpiderMonkey’s decompiler has been removed.Β  This slightly reduces the size of the “script-data” entries in about:memory.

I modified js::Vector so that it doesn’t waste space when its elements have a size that is not a power of two.

B2G

Chris Jones fixed a bad leak in the IPC code.Β  This is a big deal because B2G testing has found several cases of steadily growing memory consumption that lead to the devices becoming unusable, and there’s a good chance that this leak was responsible for some of them.Β  More testing is needed to determine exactly how many problems this has fixed.

It’s not surprising that IPC code is causing B2G problems, because that is code that desktop Firefox uses only lightly (for out-of-process plug-ins), whereas B2G uses it very heavily.Β  There’s a bug open for detecting such leaks that should be fairly easy to implement, and potentially could lead to big fixes, which is currently looking for an owner.

Miscellaneous

Timothy Nikkel reduced the memory consumed by display:none elements.Β  This was a tricky bug that was landed and then backed out multiple times due to subtle test failures.Β  And while this bug has benefits of its own, it is most notable for the fact that it was blocking bug 689623, which is the key bug that will help us start to fix Firefox’s problems with image-heavy pages.Β  (And 689623 itself is close to landing now, with 13 r+’d patches.)

Matthew Gregan fixed a bug, present only in Firefox 17 ESR, that was causing HTML5 videos to consume multiple GiBs of memory.

Alexandre Poirot fixed another leak in the Add-on SDK.

Jonathan Kew reduced the amount of memory consumed by textruns when Facebook Messenger is enabled.

David Keeler fixed a leak relating to IndexedDatabaseManager.

Bug Counts

Here are the current bug counts.

  • P1: 17 (-7/+8)
  • P2: 128 (-10/+19)
  • P3: 117 (-2/+15)
  • Unprioritized: 2 (-22/+2)

Lots of movement there.Β  The -7 P1s is mostly due to a number of bugs being downgraded;Β  these were bugs that seems important previously but now seem less important.Β  (For those who are interested, the bug numbers were: 679942, 763252, 764220, 770612, 819839, 829417, 833518.)