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

View File

@@ -0,0 +1,48 @@
==============================================================================
ZGC / G1 open-loop latency harness
==============================================================================
collector : ZGC Minor Cycles + ZGC Minor Pauses + ZGC Major Cycles + ZGC Major Pauses
java : 25.0.3+9-LTS-195
threads=4 rate=20,000/s warmup=20s measure=60s
liveSet=150,000 entries x 4,096 B (~585 MB live)
garbage=16,384 B/request reads=64/request mutationProbability=0.20
nominal allocation rate ~328 MB/s seed=20260730
------------------------------------------------------------------------------
building live set ... 150,000 entries, ~589 MB live, took 310 ms
warming up for 20 s at 20,000 req/s ...
measuring for 60 s at 20,000 req/s ...
------------------------------------------------------------------------------
achieved throughput : 19,973 req/s over 60.1 s
RESPONSE TIME (from intended arrival -- the honest number) (n=1,200,000)
mean 0.016 ms
p50 0.006 ms
p90 0.009 ms
p99 0.029 ms
p99.9 1.437 ms
p99.99 23.675 ms
max 32.178 ms
SERVICE TIME (from actual start -- hides queueing) (n=1,200,000)
mean 0.007 ms
p50 0.006 ms
p90 0.009 ms
p99 0.025 ms
p99.9 0.143 ms
p99.99 0.269 ms
max 8.353 ms
coordinated-omission gap at p99.9 : 1.437 ms response vs 0.143 ms service (10.0x)
GC activity during the measured window
ZGC Minor Cycles collections=18 time= 919 ms [cycle (mostly concurrent)]
ZGC Minor Pauses collections=54 time= 0 ms [stop-the-world]
ZGC Major Cycles collections=3 time= 667 ms [cycle (mostly concurrent)]
ZGC Major Pauses collections=15 time= 0 ms [stop-the-world]
CSV (response time)
collector,n,mean_ms,p50_ms,p90_ms,p99_ms,p999_ms,p9999_ms,max_ms
ZGC Minor Cycles + ZGC Minor Pauses + ZGC Major Cycles + ZGC Major Pauses,1200000,0.016,0.006,0.009,0.029,1.437,23.675,32.178
liveSet checksum: 1