12

I'm developing a imaging processing Java 7u80 application using C++ libraries through JNI.

As I was willing to execute streams in parallel with Java 8u60, I just switched to JDK 8 and relaunched all my unit tests.

Java 8u60 Overall duration: **35'408 [ms]**
Java 7u80 Overall duration: **29'581 [ms]**

Java 7 is in my case 17% faster than Java 8 (same code, code level resp. 7 and 8).

  1. I was wondering if such result may be specific to my application or if others have already notice a downgrade of the performance moving form Java 7 to 8?
  2. Are there particular optimization to do in the code to get the best of Java 8?

If nothing can be done, I would then rather implement the multithreading code with Java 7 rather than 8, to keep the performance gain I already have with Java 7.

Mosam Mehta
  • 1,658
  • 6
  • 25
  • 34
Hey StackExchange
  • 2,057
  • 3
  • 19
  • 35
  • 2
    Using parallel streams will be slower unless used correctly. Assuming your unit tests are not running [jmh](http://openjdk.java.net/projects/code-tools/jmh/) you can ignore the numbers completely. – Boris the Spider Oct 09 '15 at 13:00
  • 2
    @BoristheSpider I believe the OP haven't used stream yet, he just did the switch of JDK version and immediately noticed the change in overall duration. – Jean-François Savard Oct 09 '15 at 13:02
  • @Jean-FrançoisSavard in that case only the second part of my comment applies. – Boris the Spider Oct 09 '15 at 13:03
  • 2
    You'll want to read http://stackoverflow.com/questions/504103/how-do-i-write-a-correct-micro-benchmark-in-java . – VGR Oct 09 '15 at 13:07
  • 1
    @VGR, If it's 35 and 29 seconds, it's not a *micro*benchmark. – Tagir Valeev Oct 09 '15 at 14:07
  • 1
    No, there's no overall degradation of performance in Java-8, usually it's somewhat faster, though it's fully depend on the usage scenario. Try to profile your code to find exact places where it becomes slower. – Tagir Valeev Oct 09 '15 at 14:08
  • 4
    Unit tests are usually the last thing to tell you something about performance. They perform most of the operations exactly once, just to prove they don’t fail. That’s way different from the production environment behavior (and that’s by intention). – Holger Oct 09 '15 at 14:24
  • 1
    Java8 *should* be more performant in [general](http://www.optaplanner.org/blog/2014/03/20/HowMuchFasterIsJava8.html). Of course you may find corner/specific cases where not. I won't discuss Java vs C++ performance, but if you are already with C++ by JNI why you are process with Java anyway ? – PeterMmm Oct 09 '15 at 14:54
  • 1
    If you want to get your tests to run faster that's probably possible with fiddling on a few VM settings, but as @Holger mentions that has little to do with production performance and more with transient startup effects. – the8472 Oct 09 '15 at 16:19

1 Answers1

6

Launched 21 SOAPUI (Parallel) tests against WLS 12.1.3 running resp. Java 7u51(*) and Java 8u60 on my test environment.

Test results below (screenshots included in case of).

To summarize: SOAPUI time is simply the SOAPUI execution time for each pass, while
the JMX time (cumulative between each pass) is the time spend on the critical part of my application.
The JMX metrics is the computational time (the one I try to minimize). I won't rely on the SOAPUI metric as I don't know how it is calculated exactly

As per SOAPUI, JDK 7u51 was 6.7% faster than JDK 8u60.
As per JMX, JDK 7u51 was 15.6% faster than JDK 8u60.

The latter confirm (to me) the trend observed in my unit tests - same result. Despite these tests are probably not the one to use to evaluate a JVM performance, I guess that in my case scenario, it is preferable to stay on JDK7, as in my case, the performance aspect is important.

Java 7
Pass1 SOAPUI: 22'324 [ms] - JMX :16'286 [ms]
Pass2 SOAPUI: 24'129 [ms] - JMX :33'510 [ms]
Pass3 SOAPUI: 22'170 [ms] - JMX :49'923 [ms]
TOTAL SOAPUI: 68'623 [ms] (JMX: 49'923 [ms])

Java 8
Pass1 SOAPUI: 25'150 [ms] - JMX :19'767 [ms]
Pass2 SOAPUI: 24'564 [ms] - JMX :39'702 [ms]
Pass3 SOAPUI: 23'846 [ms] - JMX :59'172 [ms]
TOTAL SOAPUI: 73'560 [ms] (JMX: 59'172 [ms])

(*): no time to install Java 7u60 as in my unit test

Screenshots

enter image description here

Hey StackExchange
  • 2,057
  • 3
  • 19
  • 35
  • The real advantage on performance of Java 8 against 7 is on multithreading, say the Fork-Join model. The image is a nice idea, though it is too small to appreciate the values. – another Nov 21 '16 at 13:03