Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why aren't there more pauseless GC's

All the GC's I know except Azul are somewhat concurrent, but have at least some small stop-the-world component. Why aren't there more GC's like Azul?

Did Azul patent their technology to the extent that it's not possible to do?

Or do the read/write barriers needed for pauseless operation incur so much overhead that they are impractical for most workloads?

like image 614
Pepijn Avatar asked Nov 10 '14 09:11

Pepijn


3 Answers

Based on the Azul whitepaper on C4, it looks like C4 is a very new technology, an implementation of an algorithm published in 2005, first on custom hardware and then ported specifically to Linux on x86, and the JVM implementation sits very close to the kernel VM system.

Since OpenJDK/HotSpot is widely used on a number of platforms and in major production workloads, it tends to move more slowly when adopting major innovations in algorithms (the switch to TimSort is a good example). The Java 8 versions introduced the first major overhaul of the GC system in years (with the elimination of the PermGen), and improvements such as C4, if practical to be ported cross-platform or abstracted without significant downside to JVM bookkeeping internals, are likely to be tried out and then adopted into OpenJDK/HotSpot in upcoming versions.

like image 114
chrylis -cautiouslyoptimistic- Avatar answered Nov 17 '22 19:11

chrylis -cautiouslyoptimistic-


Implementing garbage collectors is quite tricky and there are not many applications that truly justify a pauseless collector. As you mentioned, read/write barriers to impose a pretty high overhead that you only want to pay if you absolutely need low latency and are willing to take a hit on throughput.

That said, a low-pause GC called Shenandoah is being implemented in this JEP: http://openjdk.java.net/jeps/189 . As a Java programmer, I'm hopeful that it will be available in a few years.

like image 8
Joshua Hartman Avatar answered Nov 17 '22 19:11

Joshua Hartman


ZGC

Starting from Java 11, there is a new Z Garbage Collector (ZGC) available for Linux/x64 JDK (Windows/macOS since Java 14):

The Z Garbage Collector, also known as ZGC, is a scalable low latency garbage collector designed to meet the following goals:

  • Pause times do not exceed 10ms
  • Pause times do not increase with the heap or live-set size
  • Handle heaps ranging from a few hundred megabytes to multi terabytes in size

You can enable ZGC by specifying the following JVM arguments:

-XX:+UnlockExperimentalVMOptions -XX:+UseZGC

(For Java 15+, -XX:+UnlockExperimentalVMOptions is unnecessary)


Shenandoah GC

Also, since Java 12, there is Shenandoah GC available for all platforms. ShenandoahGC has similar characteristics as ZGC but its implementation is different.

-XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC

(For Java 15+, -XX:+UnlockExperimentalVMOptions is unnecessary)

Shenandoah GC was also backported to Java 11 (11.0.9) and Java 8 (only RedHat builds of JDK 8 include Shenandoah).

like image 4
ZhekaKozlov Avatar answered Nov 17 '22 20:11

ZhekaKozlov