1
0

Generational ZGC vs G1 on JDK 25: benchmarks, internals and captured results

Complete companion suite for the ankurm.com guide. Everything was compiled and
executed on java 25.0.3+9-LTS-195 (AMD Ryzen 5 5600U, Windows 11); every file
under results/ is unedited program output.

Code
  latency/    open-loop latency harness that measures from intended arrival, so
              coordinated omission is accounted for rather than hidden. Reports
              response time and service time side by side; the gap reached 2910x
              on G1.
  jmh/        four microbenchmarks isolating one mechanism each: TLAB allocation,
              the ZGC load barrier (with a primitive-load control), the write
              barrier (with null / old-to-old / primitive controls), and promotion
              pressure.
  tuning/     provokes ZGC allocation stalls and reads its own JFR recording back,
              grouped by page class. jdk.ZAllocationStall is enabled without a
              threshold, because the 10 ms default hides most stalls.
  internals/  ZGC page classes vs G1 humongous, read from the live VM via
              HotSpotDiagnosticMXBean and jdk.ZPageAllocation events.
  analysis/   unified GC log parser that keeps stop-the-world pauses and
              concurrent phases in separate buckets.
  env/        environment capture; proves generational mode from JMX bean names.

Docs
  Eight chapters covering the JEP 439/474/490 timeline, colored pointers and both
  barriers, allocation stalls, a full flag reference, logging and JFR, benchmark
  methodology, corner cases, and a decision procedure.

Headline result (60 s, 20k req/s, 2 GB heap, ~585 MB live)
  p50               ZGC 0.006 ms   G1 0.005 ms
  p99.9             ZGC 1.437 ms   G1 95.169 ms
  total STW time    ZGC 1.503 ms   G1 1,139.624 ms
This commit is contained in:
2026-07-31 08:47:16 +05:30
commit e189da79ba
45 changed files with 12572 additions and 0 deletions

36
results/06-gclog-zgc.txt Normal file
View File

@@ -0,0 +1,36 @@
==============================================================================
GC log analysis: zgc-latency.log
==============================================================================
lines parsed : 2,247
young / minor cycles : 45
old / major cycles : 17
ZGC allocation stalls : 40
G1 evacuation failures : 0
full GCs : 0
STOP-THE-WORLD PAUSES (this is application freeze time)
count : 106
total : 1.503 ms
mean : 0.014 ms
p50 : 0.014 ms
p99 : 0.044 ms
max : 0.054 ms
by phase
Pause Mark Start (Major) n=8 total= 0.139 ms max= 0.021 ms
Pause Mark End n=38 total= 0.683 ms max= 0.044 ms
Pause Relocate Start n=38 total= 0.330 ms max= 0.021 ms
Pause Mark Start n=22 total= 0.351 ms max= 0.054 ms
CONCURRENT PHASES (application keeps running -- NOT freeze time)
Concurrent Mark n=38 total= 894.499 ms max= 78.403 ms
Concurrent Mark Free n=38 total= 0.097 ms max= 0.033 ms
Concurrent Reset Relocation Set n=38 total= 4.331 ms max= 0.934 ms
Concurrent Select Relocation Set n=38 total= 48.991 ms max= 5.372 ms
Concurrent Relocate n=38 total=1092.392 ms max=151.380 ms
Concurrent Process Non n=8 total= 5.635 ms max= 0.984 ms
Concurrent Remap Roots n=8 total= 10.919 ms max= 2.207 ms
Adding the block above to the pause block would be a category error:
concurrent time overlaps application execution by design.