JDK-8307059 : Implementation of Generational ZGC
  • Type: CSR
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21
  • Submitted: 2023-04-27
  • Updated: 2023-05-05
  • Resolved: 2023-05-05
Related Reports
CSR :  
Description
Summary
-------

The proposed change introduces a new version of ZGC, named Generational ZGC. This version of ZGC can be turned on with the new product flag -XX:+ZGenerational.

Problem
-------

We want to improve application performance by extending the Z Garbage Collector (ZGC) to maintain separate generations for young and old objects. This will allow ZGC to collect young objects — which tend to die young — more frequently.

For more details see JEP 439:
https://openjdk.org/jeps/439

Solution
--------

The JEP describes the new Generational ZGC.

Our first suggested approach was to remove the old ZGC code and replace it with the new, Generational ZGC. However, different GC implementations have different performance characteristics, which could effect some current users. Therefore it was decided that that we should keep both versions in, at least, the release where Generational ZGC is introduced. The intention is to pave the way for a smoother transition of users from the old ZGC to the new Generational ZGC.

User running with -XX:+UseZGC will get the old ZGC version. Users running with -XX:+UseZGC -XX:+ZGenerational will get the new Generational ZGC.

Specification
-------------
Generational ZGC code:
https://github.com/openjdk/zgc/tree/zgc_generational

This is the version where we retain the old version:
https://github.com/stefank/jdk/tree/zgc_generational_include_single_gen_code_as_x

When -XX:+ZGenerational is used the GC will react to a few new product flags:

* -XX:ZYoungCompactionLimit - "Maximum allowed garbage in young pages" - Default: 25.0 (range between 0-100%)
* -XX:ZCollectionIntervalMinor - "Force Minor GC at a fixed time interval (in seconds)" - The flag is ignored unless the user sets it.
* -XX:ZCollectionIntervalMajor - "Force GC at a fixed time interval (in seconds)" - The flag is ignored unless the user sets it.
* -XX:ZYoungGCThreads - "Number of GC threads for the young generation" - The value of this flag is set ergonomically if the user didn't set the flag.
* -XX:ZOldGCThreads - "Number of GC threads for the old generation" - The value of this flag is set ergonomically if the user didn't set the flag.

Because Generational ZGC has two generations and the old ZGC only had one, there will be a difference in the number entities in various serviceability layers:

Memory Pools:

* Old ZGC: "ZHeap"
* Generational ZGC: "ZGC Young Generation", "ZGC Old Generation"

Memory Managers:

* Old ZGC: "ZGC Cycles", "ZGC Pauses"
* Generational ZGC: "ZGC Minor Cycles", "ZGC Minor Pauses", "ZGC Major Cycles", "ZGC Major Pauses"

The same is true for the HotSpot performance counters.
Comments
Moving to Approved.
05-05-2023

Moving to Provisional, not Approved. Please include a short problem statement in the CSR before it is Finalized.
27-04-2023

Thanks, Vladimir. I've updated the text with comments about the flags.
27-04-2023

Also what are default values of these flags?
27-04-2023

Is -XX:+ZGenerational additional flag to -XX:+UseZGC to be specified? Are all new flags "product"?
27-04-2023