JDK-8210966 : Revamp G1 jstat counter definitions
  • Type: CSR
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P4
  • Status: Draft
  • Resolution: Unresolved
  • Submitted: 2018-09-20
  • Updated: 2018-10-18
Related Reports
CSR :  
Description
Summary
-------

JDK-8196991 revamps the G1 JMX MXBean definitions. This CSR revamps the G1 jstat counter definitions in a corresponding way.

Problem
-------

See Summary.

Solution
--------

The current G1 jstat counters are:
```
sun.gc.collector.0 : Incremental (pure young and mixed) collector, corresponds to
"G1 Young Generation"
sun.gc.collector.1 : Full heap STW collector, corresponds to "G1 Old Generation"
sun.gc.collector.2 : Concurrent cycle STW phases, corresponds to
"G1 Concurrent Cycle"

sun.gc.generation.0 : "young" generation, composed of 3 spaces
sun.gc.generation.0.space.0 : "eden", corresponds to "G1 Eden Space"
sun.gc.generation.0.space.1 : "s0", the from survivor space, unused
sun.gc.generation.0.space.2 : "s1", the to survivor space, corresponds to
"G1 Survivor Space"

sun.gc.generation.1 : "old" generation, composed of 1 space
sun.gc.generation.space.0 : "space", including old, humongous, and archive
regions, corresponds to "G1 Old Gen"
```
The new and redefined jstat counters are:
```
sun.gc.collector.3 : Pure young collector, corresponds to "G1 Young"
sun.gc.collector.4 : Mixed collector, corresponds to "G1 Mixed"

sun.gc.generation.1 : "old" generation, composed of 3 spaces
sun.gc.generation.space.0 : "space", including only old regions, corresponds to
"G1 Old Space"
sun.gc.generation.space.1 : "humongous", including only humongous regions,
corresponds to "G1 Humongous Space"
sun.gc.generation.space.2 : "archive", including only archive regions,
corresponds to "G1 Archive Space"
```
Unlike the GarbageCollector and MemoryPool MXBean definitions, all existing counters are active regardless of G1UseLegacyMonitoring. The only behavioral difference is that if G1UseLegacyMonitoring is true, sun.gc.generation.space.0 retains its legacy inclusion of old, humongous, and archive regions. If false, it includes only old regions.

--------

The current result of "jcmd GC.heap_info" is, for example:

 garbage-first heap total 17408K, used 6274K [0x00000007e0000000, 0x0000000800000000)
  region size 1024K, 2 young (2048K), 1 survivors (1024K)
 Metaspace used 22223K, capacity 22871K, committed 23088K, reserved 1069056K
  class space used 2575K, capacity 2894K, committed 2944K, reserved 1048576K

The new result looks like:

 garbage-first heap total 17408K, used 5600K [0x00000007e0000000, 0x0000000800000000)
  region size 1024K, 2 young (2048K), 1 eden (1024K), 1 survivor (1024K), 4 old (4096K), 1 humongous (1024K), 0 archive (0K)
 Metaspace used 20788K, capacity 21365K, committed 21552K, reserved 1069056K
  class space used 2400K, capacity 2645K, committed 2688K, reserved 1048576K

--------

By default, all the jstat GC options now include information about pure young and mixed collections, and about humongous and archive regions. Here are the new column headers and their meanings.
```
HC    : sun.gc.generation.space.1.capacity humongous committed size in kb
HU    : sun.gc.generation.space.1.used humongous used size in kb
AC    : sun.gc.generation.space.2.capacity archive space committed size in kb
AU    : sun.gc.generation.space.2.used archive space used size in kb
PYGC  : sun.gc.collector.3.invocations pure young collection count
PYGCT : sun.gc.collector.3.time/sun.os.hrt.frequency pure young collection
stop-the-world time
MGC   : sun.gc.collector.4.invocations mixed collection count
MGCT  : sun.gc.collector.4.time/sun.os.hrt.frequency mixed collection
stop-the-world time
H     : (sun.gc.generation.1.space.1.capacity - sun.gc.generation.1.used)/100
humongous space, percent used
A     : (sun.gc.generation.1.space.2.capacity - sun.gc.generation.2.used)/100
archive space, percent used
```
Here are old and new sample outputs for the various jstat options. Most of the fields have been widened so that up to 3-digit gigabyte sizes can be accommodated. See the file src/jdk.cmd/share/classes/sun/tools/jstat/resources/jstat_options for details.

As for the other G1-specific fields, a '-' is written as the field value if the collector in use is not G1.

In legacy mode, the old space counters include old, humongous and archive regions. In the new mode, old space counters include only old regions. In both modes, humongous and archive region information is correct.

jstat gc

S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT CGC CGCT GCT
S0C S1C S0U S1U EC EU OC OU HC HU AC AU MC MU CCSC CCSU YGC YGCT FGC FGCT CGC CGCT PYGC PYGCT MGC MGCT GCT

jstat gccapacity

NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC CGC
NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC HC AC MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC CGC PYGC MGC

jstat gccause

S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT LGCC GCC
S0 S1 E O H A M CCS YGC YGCT FGC FGCT CGC CGCT PYGC PYGCT MGC MGCT GCT LGCC GCC

jstat gcnew

S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT PYGC PYGCT MGC MGCT

jstat gcnewcapacity

NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC CGC
NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC CGC PYGC MGC

jstat gcold

MC MU CCSC CCSU OC OU YGC FGC FGCT CGC CGCT GCT
MC MU CCSC CCSU OC OU HC HU AC AU YGC YGCT FGC FGCT CGC CGCT PYGC PYGCT MGC MGCT GCT

jstat gcoldcapacity

OGCMN OGCMX OGC OC YGC FGC FGCT CGC CGCT GCT
OGCMN OGCMX OGC OC HC AC YGC YGCT FGC FGCT CGC CGCT PYGC PYGCT MGC MGCT GCT

jstat gcmetacapacity

MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC FGCT CGC CGCT GCT
MCMN MCMX MC CCSMN CCSMX CCSC YGC YGCT FGC FGCT CGC CGCT PYGC PYGCT MGC MGCT GCT

jstat gcutil

S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT
S0 S1 E O H A M CCS YGC YGCT FGC FGCT CGC CGCT PYGC PYGCT MGC MGCT GCT

Specification
-------------

No specification change is necessary, since the jstat counter definitions and output formats are not formally defined.


Comments
> "The only behavioral difference is that if G1UseLegacyMonitoring is true, sun.gc.generation.space.0 retains its legacy inclusion of old, humongous, and archive regions. If false, it includes only old regions." It should be "sun.gc.generation.1.space.0", right? Similarly, other occurrences of sun.gc.generation.space.0, sun.gc.generation.space.1, sun.gc.generation.space.2 should probably be "sun.gc.generation.1.space.N". A high-level comment is that since the G1UseLegacyMonitoring is already changing the meaning of sun.gc.generation.1.space.0, could it also change the meaning of sun.gc.collector.N, so they are more straightforward and consistent with the new GarbageCollectorMXBeans in JDK-8196991? I.e., without G1UseLegacyMonitoring, the counters are: sun.gc.collector.0 : Pure young collector, corresponds to "G1 Young" sun.gc.collector.1 : Mixed collector, corresponds to "G1 Mixed" sun.gc.collector.2 : Concurrent cycle STW phases, corresponds to "G1 Concurrent Cycle" sun.gc.collector.3 : Full heap STW collector, corresponds to "G1 Full" Basically since there are already separate counters for "Pure young" and "Mixed" collectors, the counters for "Incremental (pure young and mixed) collector" are redundant. And intuitively, as the suffix number N increases, the collectors are for increasingly larger part of the heap. This is also consistent with other collectors such as CMS and ParallelGC.
18-10-2018