Reputation: 113
at the moment I'm trying to extend my knowledge about GC algorithms. What I can't comprehend right now is why the first phase of the CMS GC - the initial mark - is displayed everywhere as serial thread. Why isn't it done in parallel like the remarkin phase, which is also a STW?
Thanks you in advance for your help.
Upvotes: 1
Views: 100
Reputation: 8379
Majority of work during initial mark is scanning of young space for young-to-old references (they are GC root from old space point of view).
That work could be parallelized by splitting memory to scan into chunks for parallel processing. Though splitting memory requires JVM track exact addresses of object first byte in memory region as memory cannot be parsed from address in the middle of object.
For old space this is solved by tracking offset for first object in memory page in array (page is 512 byte).
For young space "probing" is used (in some interval, start address of last allocated object is recorder), but for long time it was enabled only during preclean phase of CMS.
In 2013, Hiroshi Yamauchi has contributed a patch to OpenJDK which enables parallel initial mark on CMS.
Initial mark is actually parallel now.
Upvotes: 2