ParNew and CMS-Initial Correlation
garbage-collection, jvm
Solution
Normally CMS initial mark piggyback on young collection. CMS can wait for young collection for some time (2 seconds default). If it is not happening, initial mark will scan all young space using single thread, this could be very time consuming.
Read http://blog.ragozin.info/2011/06/understanding-gc-pauses-in-jvm-hotspots_02.html for more details.
HotSpot option –XX:CMSWaitDuration=<delay in ms> controls how long CMS initial mark could be delayed to piggyback young collection.
Problem
I have observed that when there is no recent ParNew and then if the CMS-Initial-Mark phase kicks-in, the CMS-Initial-Mark phase takes longer time to mark the objects in old generation. The good part is most of the times I found ParNew (may be by chance or JVM does this internally) occurs just before CMS-Initial-Mark phase and then to mark the same number of objects in old generation, the CMS takes less time. Would like to know the reasoning behind this observation. Note: Considering, CMS-Initial-Mark phase is stop-the-world, the best attempt should be made to reduce its duration.