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

47
results/03-latency-g1.txt Normal file
View File

@@ -0,0 +1,47 @@
==============================================================================
ZGC / G1 open-loop latency harness
==============================================================================
collector : G1 Young Generation + G1 Concurrent GC + G1 Old Generation
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 266 ms
warming up for 20 s at 20,000 req/s ...
measuring for 60 s at 20,000 req/s ...
------------------------------------------------------------------------------
achieved throughput : 19,976 req/s over 60.1 s
RESPONSE TIME (from intended arrival -- the honest number) (n=1,200,000)
mean 0.388 ms
p50 0.005 ms
p90 0.009 ms
p99 8.042 ms
p99.9 95.169 ms
p99.99 126.949 ms
max 133.018 ms
SERVICE TIME (from actual start -- hides queueing) (n=1,200,000)
mean 0.007 ms
p50 0.005 ms
p90 0.008 ms
p99 0.016 ms
p99.9 0.033 ms
p99.99 0.171 ms
max 113.864 ms
coordinated-omission gap at p99.9 : 95.169 ms response vs 0.033 ms service (2910.4x)
GC activity during the measured window
G1 Young Generation collections=36 time= 604 ms [stop-the-world]
G1 Concurrent GC collections=19 time= 15 ms [cycle (mostly concurrent)]
G1 Old Generation collections=2 time= 208 ms [stop-the-world]
CSV (response time)
collector,n,mean_ms,p50_ms,p90_ms,p99_ms,p999_ms,p9999_ms,max_ms
G1 Young Generation + G1 Concurrent GC + G1 Old Generation,1200000,0.388,0.005,0.009,8.042,95.169,126.949,133.018
liveSet checksum: 0