G1 Performance [Was: JEP 248: Make G1 the Default Garbage Collector]
aph at redhat.com
Wed Jul 29 16:09:45 UTC 2015
On 06/25/2015 06:10 PM, Staffan Friberg wrote:
> * *Throughput* - Code Performance
> o The pure application performance should not be too adversely
> affected by which GC is used.
> o Due to the heavier write barriers used in G1 there may be a
> performance impact. But the impact varies for different
> o *Goal:* The performance is good enough so the general
> recommendation does not end up being to set the Parallel GC as
> part of application launch scripts.
I 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
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
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
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.
More information about the hotspot-dev