1

As after Jrockit is no more available, hence is there any way to achieve deterministic (no more that x ms) GC pause? I am trying with G1 GC in java_8_65 but it is non-deterministic and many times i see young gc pauses greater than -XX:MaxGCPauseMillis which is expected but not as per my requirement.

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
Laxmikant
  • 1,551
  • 1
  • 13
  • 30

4 Answers4

3

The simple answer is no. All GC used by Hotspot and other JVMs (like Zing from Azul, who I work for) are inherently non-deterministic. You can certainly tune a GC to achieve your latency goal for most of the time and using Zing would give you much more reliable results because it performs a compacting collection truly concurrently with the application threads (so, therefore, does not have stop-the-world pauses).

The problem is that, if your application suddenly hits a point where it starts allocating objects at a much higher rate or generates garbage much faster than you have tuned for, you will start seeing pauses that exceed your goal. This is simply the way GC works.

The only way to get true deterministic behaviour like you're looking for would be to use a real-time JVM (look up the RTSJ spec) that would also require a real-time operating system underneath. The drawback to doing this is often your throughput will suffer.

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
Speakjava
  • 3,177
  • 13
  • 15
  • the question mentions jrockit, so it seems to be implied that RTSJ-levels of determinism aren't required, just as good as whatever its GCs managed. – the8472 Jun 28 '18 at 18:42
1

Your options are

  • do some tuning until G1 performs as expected
  • switch to another collector available in the JVM you're using, e.g. CMS
  • switch to a different JVM which offers collectors with stronger guarantees
  • optimize your application to reduce GC pressure or worst case behavior
  • throw more hardware at the problem (more or faster CPU cores, more RAM)
the8472
  • 40,999
  • 5
  • 70
  • 122
  • currently doing the G1 gc tuning (having hard time thogh :)) ...dont want to move to CMS as it will be depricated as per http://openjdk.java.net/jeps/291 – Laxmikant Jun 28 '18 at 18:51
1

One other options could be OpenJ9 Metronome GC. As far as I know, it is design for deterministic, short pauses for real time apps. According to the documentation the default is 10 millisecond pauses. However, it will of course need more CPU and is more design for small heaps.

I never used it, so I cannot share any experience.

Gamlor
  • 12,978
  • 7
  • 43
  • 70
1

The release of Java 11 contains a brand new Garbage Collector, ZGC, that promises very low pause times.

The goal of this project is to create a scalable low latency garbage collector capable of handling heaps ranging from a few gigabytes to multi terabytes in size, with GC pause times not exceeding 10ms.

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259