CONCURRENT MARK SWEEP (CMS) COLLECTOR:
CMS is like serial process where memory is allocated in such a way that eden, survivor, old/tenured and permanent generations. And the objects need to be moved from one generation to other verifying the lively ness.
Its a low pause collector, imples it collects tenured generation, minimize the pauses due to garbage collection by doing most collection by doing most collection work concurrently with the application threads. For young generation uses same as parallel collector.
GARBAGE FIRST (G1GC)
In G1GC, the complete heap is divided in to chunks (~2000) where collector is parallel, concurrent and incrementally compacting low pause garbage collector.
Old generation: Single threaded
Compaction: Multi threaded for young and single threaded for old
Flags: -XX:+UseParallelGC
Young generation: multithreaded (Choose less than or equal to number of CPU cores, not include hyperthreads, for number of core check by command "lscpu" = Core(s) per socket * Socket(s) )
Flags:
JVM_OPTS="$JVM_OPTS -XX:ParallelGCThreads=[Core(s) per socket * Socket(s)]"
JVM_OPTS="$JVM_OPTS
-XX:ConcGCThreads=[1/4 th of (Core(s) per socket * Socket(s))]
"
Enable Parallel referencing:
JVM_OPTS="$JVM_OPTS
-XX:+ParallelRefProcEnabled"
Delay region scanning: Java 8 by default is 40%
JVM_OPTS="$JVM_OPTS
-XX:InitiatingHeapOccupancyPercent=70"
Enable GC logging:
JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
JVM_OPTS="$JVM_OPTS
-XX:+PrintGCDateStamps"
JVM_OPTS="$JVM_OPTS
-XX:+PrintHeapAtGC"
JVM_OPTS="$JVM_OPTS
-XX:+PrintTenuringDistribution"
JVM_OPTS="$JVM_OPTS
-XX:+PrintGCApplicationStoppedTime"
JVM_OPTS="$JVM_OPTS
-XX:+PrintPromotionFailure"
JVM_OPTS="$JVM_OPTS
-XX:PrintFLSStatistics=1"
JVM_OPTS="$JVM_OPTS
-Xloggc:/var/log/cassandra/gc-`date +%s`.log"
Flags: -XX:+UseParallelOldGC
This flag implies, all generations are multi threaded like young, old and for compaction also.
For monitoring your GC log easily and threads, try these websites.
1)
www.gceasy.io
2)
www.fastthread.io
***