Skip to content

Switch to ZGC for JCentral

Volodymyr Yurchenko requested to merge switch-to-zgc into master

This commit changes the garbage collector used by JCentral from the default G1GC to ZGC.

About ZGC

The Z Garbage Collector is focussed on achieving the millisecond-scale pause times (the duration during which the garbage collector stops the application). It is suitable for applications which require low latency. Pause times are independent of heap size that is being used.

Advantages of ZGC

  • Sub-Millisecond Max Pause Times: ZGC now has O(1) pause times of under 1ms that don’t increase with the heap or root-set size.
  • Dynamic Number of GC Threads (enabled by default): With ZGC’s support for this feature in JDK 17, it optimizes thread usage to collect garbage without excessive CPU consumption efficiently, ensuring more CPU time is available for Java threads.
  • Fast JVM Termination: ZGC was improved to quickly reach a safe state on demand by aborting ongoing garbage collection cycles. As a result, terminating a JVM running ZGC is now nearly instantaneous.

Disadvantages of ZGC

  • ZGC may require a higher heap size to achieve the throughput goal (which is by default set to 99 work/gc time ratio)

See those articles about ZGC: [1], [2]

Selecting a Collector

(extract from here)

  • If the application has a small data set (up to approximately 100 MB), then select the serial collector with the option -XX:+UseSerialGC.
  • If the application will be run on a single processor and there are no pause-time requirements, then select the serial collector with the option -XX:+UseSerialGC.
  • If (a) peak application performance is the first priority and (b) there are no pause-time requirements or pauses of one second or longer are acceptable, then let the VM select the collector or select the parallel collector with -XX:+UseParallelGC.
  • If response time is more important than overall throughput and garbage collection pauses must be kept shorter, then select the mostly concurrent collector with -XX:+UseG1GC.
  • If response time is a high priority, then select a fully concurrent collector with -XX:UseZGC.

Other minor changes

  • The MaxTrivialSize option has been moved to JAliEn JVM options
  • The OptimizeStringConcat option has been removed since it's enabled by default

Merge request reports