Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GC in Java 8 get obviously slower compare to Java 7

I have a server with 72 GB memory running, it was use Java 7 with parallel GC and heap size in 25G. But after switch into Java 8, a particular task get much slower. The task basically read a file around 15GB in the memory, and update some relevant data in DB. It usually takes around one hour to finished the job, but after Java 8, it becomes 1.5 hours.

I tried:

  1. Increase heap size to 50GB => not help
  2. Change GC algorithm from parallel to CMS, it becomes even slower (1.8 hour)

So I am not sure where I can start to have a look, the java library to run the task is still compiled in Java 7 but I am not sure if this relevant? After switch to Java 7, the performance just came back.

like image 976
Chia-Chuan Wu Avatar asked Apr 22 '16 01:04

Chia-Chuan Wu


People also ask

What is the fastest garbage collector in Java 8?

Executive summary. For your convenience, I 've compared each Garbage Collector type to the default in Java 8 (Parallel GC). The results are clear: That default (Parallel GC) is the fastest.

What is the default GC in Java 7?

Java 7 64-bit, you get Parallel GC (for both young and old generations) by default.

Is Java garbage collection slow?

GC is slow, mostly because it needs to pause program execution to collect garbage.

Which GC used in Java 8?

Parallel/Throughput GC This is JVM's default collector in JDK 8. As the name suggests, it uses multiple threads to scan through the heap space and perform compaction. A drawback of this collector is that it pauses the application threads while performing minor or full GC.


1 Answers

To compare/find GC issue, it's better to enable GC logging:

  • -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:logs/gc.log

and use GCViewer to parse/visualize GC log files. It will be useful if you gather GC log and attach it to question.

In theory (and practice), Java 8 is faster than Java 7. You mentioned that Java writes data to DB. It may be worth to analyze resource consumption of both, may be DB is root cause.

like image 130
Michael Zhilin Avatar answered Oct 23 '22 22:10

Michael Zhilin