[Gc] Use Case for Incremental GC

Boehm, Hans hans.boehm at hp.com
Mon May 17 17:16:12 PDT 2010


> From: Bruce Hoult
> Sent: Wednesday, May 12, 2010 4:40 AM
> To: Volkan YAZICI
> Cc: gc at napali.hpl.hp.com
> Subject: Re: [Gc] Use Case for Incremental GC
> 
> In my opinion: never.
> 
> Incremental GC is inherently slower than non-incremental, so 
> you don't want it in long running non-interactive programs.
This is actually somewhat application specific.  Enabling
incremental mode also makes the collector somewhat generational,
i.e. it no longer has to scan the whole heap in order to reclaim
recently allocated objects.  That may reduce GC time enough
to compensate for the overhead, though probably not on a
multicore processor.

A long time ago, when this was originally developed, it often
helped a lot, because the application was paging, and not having
to touch the whole heap was a huge win.  These days, if you're
paging, you should really just buy more memory.

> 
> You can only do a certain number of incremental GCs before 
> you have to do a full one, so it's no use in video games that 
> don't want to drop frames. You either make sure that a full 
> GC is fast enough to fit into a frame time (which is usually 
> the case with modern computers, especially if you make good 
> use of GC_malloc_atomic()), or else you write your animation 
> loop in such a way that it doesn't GC at all e.g.
> by preallocating everything.
In full incremental mode, the full GC can still be interrupted
and restarted later, so pause times do decrease.  Whether or
not this is worth the overhead and the issues usually caused
by page protection will vary.  (The default pause time target is
probably too long for video games on a modern machine.  That's
tunable, but I haven't experimented with it in a long time.)

In spite of all of this, my impression is that Bruce's experience
is not that unusual, and most people in fact avoid it.

Hans

> 
> Note that in BDW GC the sweep phase is incremental and 
> distributed fairly equally throughout the running of the 
> mutator anyway, and it is only the mark phase that stops the world.
> 



More information about the Gc mailing list