Main menu:

Site search

Categories

Archive

Incremental GC now in Firefox Aurora

We’ve been holding our breath for a while on incremental GC (IGC), but now we can exhale: it’s currently in Aurora (Firefox 16) and working well. IGC comes from months of hard work by Bill McCloskey, who designed and implemented the incrementalization, and also spent a long time tuning performance and fixing the many subtle bugs that inevitably come up when you try to change the memory management of a complex system. Huge kudos to Bill for carrying through such a tough and important project.

Simply, incremental GC means fewer noticeable pauses. If you run Firefox with not too many tabs (like I do), then your GC pauses are probably around 100-200ms, which is a very noticeable glitch. If run with hundreds of tabs, then you might see pauses more like 500ms, which feels like a freeze. Incremental GC breaks up that time into 10-20ms slices, which are generally not noticeable, and spreads them out over time.

So this is a huge improvement, but keep in mind there is no perfect fix for GC pauses. For any incremental GC system, if memory is being allocated too fast, incremental GCs will not be able to keep up, and the system will be forced to pause for a full GC in order to avoid running out of memory [1]. But for the most part, IGC seems to be doing the trick, so if you’re still getting bad GC pauses, please let us know so we can fix them.

Another thing to note is that technically what’s just reached Aurora is incremental marking. Our GC has two phases, mark and sweep, and the sweep phase is not incremental yet. The last slice of GC, which includes sweeping, seems to often take 50 ms or so, which is nearly negligible for many purposes but would still disturb smooth animation.

Fortunately, Bill and Jon Coppeard (who recently joined the JS team working out of London) are making rapid progress on incremental sweeping as well. Bill is also continuing to tune IGC to keep pauses short on various machines and under various conditions.

[Update 3:11pm 20 Jul 2012: Bill reports in bug 775365 that the current work is for incrementalizing sweeping of some kinds objects. Apparently sweeping each kind of thing incrementally presents its own issues so getting incremental all the way through will take longer.]

[1] Generational GC (also under construction) will solve this problem for programs that rapidly allocate many short-lived objects. If you’re rapidly allocating long-lived objects, you’re being very mean to your GC and it will be very mean back to you.

Comments

Comment from Emanuel Hoogeveen
Time: July 20, 2012, 3:12 pm

In your update, you probably mean bug 729760 comment #11 :)

Comment from k.lang
Time: July 20, 2012, 4:22 pm

Great! Is this stuff related to IonMonkey?

Comment from dmandelin
Time: July 20, 2012, 4:25 pm

Not directly. IonMonkey is for making JS-heavy stuff run faster (throughput), IGC is for having shorter pauses.

Pingback from Aurora 16 is out — Unprefixing time ! ✩ Mozilla Hacks – the Web developer blog
Time: July 20, 2012, 11:12 pm

[…] Incremental GC, a major part in our effort to revamp our Garbage Collector, is now enabled by default. […]

Pingback from Die Aurora-Version von Firefox 16 kann mehr HTML5 | Klaus Ahrens: News, Tipps, Tricks und Fotos
Time: July 20, 2012, 11:49 pm

[…] Firefox 16 veröffentlicht. Die HTML5-Fähigkeiten des Browsers haben sich stark verbessert und die Garbage Collection wurde jetzt inkrementell gestaltet, so dass bei der Bereinigung von nicht mehr nötigen Daten keine […]