JDK-8132937 : G1 compares badly to Parallel GC on throughput on javac benchmark
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2015-08-03
  • Updated: 2024-09-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
From http://mail.openjdk.java.net/pipermail/hotspot-dev/2015-July/019482.html

"I [Andrew Haley] am concerned that G1 does not perform well with some important workloads.  In particular, on heavily-loaded systems some multi-threaded programs which generate a lot of garbage run
significantly more slowly with G1.  I've been measuring the performance loss and it's about 20-30%, depending on the application.

I don't think that this is a particularly unusual case for Java, and surely an important measure of a garbage collector is how well it works when heavily loaded in this way.

I've not been using an artificial benchmark because I don't think that it would be usefully representative.  Instead, I've written a small test case which uses the Java compiler API to compile real-world Java
code over many threads.

A typical run, of 15 seconds with 12 threads, looks like this:

 $ hs-comp/build/linux-x86_64-normal-server-release/jdk/bin/java -XX:+UseParallelGC -jar dist/CompilerSpeed.jar 15 12
12 threads, 15 seconds
Warmup
Run
Time: 15.73s, 10.68 compiles/s
 $ hs-comp/build/linux-x86_64-normal-server-release/jdk/bin/java -XX:+UseG1GC -jar dist/CompilerSpeed.jar 15 12
12 threads, 15 seconds
Warmup
Run
Time: 15.87s, 8.38 compiles/s

So, here G1 is 27% slower than the Parallel GC.  IMO it would make perfect sense to use the Parallel GC instead of G1 for this application.

I have uploaded my test case to http://people.redhat.com/~aph/CompilerSpeed.tar It's a netbeans
project.  If you'd like to try it, download it, untar it, and do this:

java -XX:+UseParallelGC -jar dist/CompilerSpeed.jar 15 12

The first number is the time in seconds to run the test for, the
second is the number of threads to use.  I normally set the number of
threads to the number of hardware threads on the machine."

Investigate the reasons for the difference, and see if there is something that can be fixed.

Comments
The benchmark seems to throw lots of Exceptions which seem to be responsible for at least part of the performance difference. JDK-8028337 describes the problem and provides a workaround.
12-08-2015

A. Haley: Running the test longer (480s?) decreases the difference to ~16%
04-08-2015