CPU / load Java application significantly higher when building with JDK8

I have a Java application developed in Eclipse Luna on Windows that runs on Amazon EC2 (c3.large, Amazon Linux). This application works with a very consistent incoming speed. When I create an application against the JDK 8u31, the load on the EC2 processor is much higher than a single application created against the JDK 7u75.

Initially, the application started with a standard JRE on EC2, and I added OpenJDK 1.8.0.31 to take advantage of the Java 8 Process waitFor (long timeout, TimeUnit unit). The main work this application does involves invoking the application using Runtime.exec.

$ sudo alternatives --config java There are 2 programs which provide 'java'. Selection Command ----------------------------------------------- * 1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java + 2 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-2.b13.5.amzn1.x86_64/jre/bin/java 

Example load when an application is built against 1.7:

 top - 00:20:28 up 4 days, 10:41, 4 users, load average: 0.37, 0.26, 0.52 

Example load when the application is built against 1.8:

 top - 23:45:52 up 4 days, 10:06, 4 users, load average: 2.28, 2.60, 2.01 

It looks like this could be due to Open JDK 1.8.0.31, but I don't know how to debug this. There are no code changes, I just change the level of compliance and build between 1.7 and 1.8 in Eclipse Luna. Any idea why the download would be so different?

UPDATE:

I see a similar high CPU load when I use Oracle JDK on EC2.

 $ sudo alternatives --config java There are 3 programs which provide 'java'. Selection Command ----------------------------------------------- 1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java 2 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-2.b13.5.amzn1.x86_64/jre/bin/java *+ 3 /usr/java/jdk1.8.0_31/bin/java 

Average load:

 top - 01:45:27 up 4 days, 12:06, 4 users, load average: 2.28, 1.50, 1.04 
+8
java eclipse java-8 amazon-ec2
source share
2 answers

You described the symptoms, but I don’t think this is enough to continue, if only because it’s impossible to look for things like “java 8 high CPU” (google, java bug parade, etc.) anywhere and) and find useful results. Unfortunately, you need to collect more information on how to use the CPU. Here are some thoughts on how to do this:

  • Profile using a tool such as VisualVM. The load differences are extreme, so you can simply determine what the processor is using.
  • Find busy threads. You can take a bunch of snapshots of the threads and the eyeball, or try a tool like jvmtop .
  • Check what the garbage collector does, either by turning on the GC log, or using a tool like jstat.
  • Use strace to track the execution of system calls.
+3
source share

The documentation says: "By default, the implementation of these methods checks exitValue to see if the process is complete. Specific implementations of this class are strongly encouraged to override this method with a more efficient implementation."

I strongly suspect that this is the reason.

See http://docs.oracle.com/javase/8/docs/api/java/lang/Process.html#waitFor--

+1
source share

All Articles