logoalt Hacker News

_old_dude_today at 3:26 PM0 repliesview on HN

All Java GCs are generational collectors, they reduce the marking time (for young collection) by tracking if there is a reference from the old generation to the new generation.

The benchmark creates an array in the old generation (by being big enough) and stores an object (allocated in the new generation). This triggers the GC barrier for every writes. Something rare in real application.

The G1 barrier before Java 26 is slow because:

- the GC barrier and some GC threads do concurrent operations on the same memory zone (the card table)

- the barrier is big (a lot of assembler instructions) so it also troubles the loop unrolling optimization performed by JITs

Parallel GC has a simple barrier and do not care about latency (no GC check inside the loop).

The barrier implementation of G1GC was changed in Java 26, so update your Java runtime version and move on.