Why serial gc evacuates the whole heap rather than just To+Old spaces?
Thomas Schatzl
thomas.schatzl at oracle.com
Sun May 26 07:33:27 UTC 2019
(cc'ed the list again, as this question has been started there and
others might have the same questions)
Hi,
On Sun, 2019-05-26 at 13:59 +0800, kelthuzadx wrote:
> Hi Thomas,
> I means, fast evacuation followers closure only need to evacuate
> To+Old spaces. Current implementation I referenced applies this
> closure on the whole young generation, but evacuation on Eden+From
> spaces is unnecessary.
as far as I understand your statements, both are incorrect. Let me
try to explain what Serial does below.
The serial gc code roughly does the following (from memory and looking
at the code for a few minutes):
- iterate the roots, copy those referenced objects to to-space or old
gen.
- these copied objects may contain references to eden/from space too.
So you need to iterate over those (only those!) objects as well.
- the code you mentioned does exactly that: at line 35 Serial GC
iterates over the objects it recently copied into to-space; at line 36
it iterates over recently copied objects in old-space.
- this process may add more objects to to-/old-space. So repeat,
until no more objects were copied into to/old space.
In no case Serial GC iterates over eden or from space (or the whole old
space).
Maybe the "young_gen()->oop_since_save_marks_iterate(cur);" line
mentioning "young_gen" is confusing? However the called method
explicitly only iterates over objects that were allocated *since* the
save marks were set... those are set at the start of every such
iteration to examine copied objects afair (There are other options to
achieve the same effect, but I think this is the case for Serial).
I would like to ask you to rephrase your question if that does not
answer your concerns, or let me understand your point better e.g. by
giving a more detailed rundown of Serial GC execution and pointing out
the location you are worried about a bit better.
Thanks,
Thomas
More information about the hotspot-gc-dev
mailing list