Search code examples
javaperformancejrockit

Java 7 JVM slower than JRockit 6?


I was very interested in upgrading to Java 7 (for my own selfish coding reasons). However, we have users who are very latency sensitive (everything needs to be sub-millisecond). I did a simple performance comparison test between 3 different JVMs and found Java 7 to be so much slower. The test pushed some simple messages through our application. This test is a low load, load volume test, which pushes a single message through, every few seconds. The results were (in microseconds):

 - Hotspot 6 (build 24): msgs= 23 avg= 902 
 - JRockit 6 (R28 b 29): msgs= 23 avg= 481 
 - Hotspot 7 (build 04): msgs= 34 avg=1130

Oracle's strategy is to merge JRockit and Hotspot starting with Java 7 (so JRockit 6 is the last available). Does anyone have any ideas why the performance is so much worse? (One point to note, is that the code was compiled under Java 1.6. Not sure if that would explain it...)

UPDATE: I voted to close my own question because I can see from the comments that I am not really able to communicate enough info to make this a constructive question. Thanks to all who commented.

UPDATE: After more feed back, I thought I would provide more info. Test is always after a fresh start. All factors are equal for each test. The only thing which changes is JVM. Repeating test multiple times gives consistent result. No GCs occurred in any test iteration.

Below is graphed values of one of the test runs. For both JRockit and Hotspot 7, the very first latency value was thrown out. JRockit has huge first value, but then very quickly optimizes and settles toward mean. Hotspot 7 takes longer to optimize, and never drops to a mean as low as JRockit. Each data point represents microseconds to read a message from TCP/IP socket, run through business logic, and write message on another socket. Every message is identical, and no new code paths are entered for any message.

JRockit 6 vs. Hotspot 7


Solution

  • The main thrust of this question was, all other things being equal (including the JVM args) why does the same JAR of Java code run so much more slowly with Hotspot 7 JVM than with JRockit 6 and Hotspot 6.

    This gave rise to a few responses concerned about whether the timing was done correctly (apparently due to people's skepticism that there could really have such a different result between the JVMs). Based on numerous tests, there is no question in my mind that the measurements are correct.

    Potential answers I thought possible were:

    • Java 7 JVM does not run code compiled under Java 6 as fast as the same code compiled under Java 7
    • new JVM args are required for Java 7 to run in most optimized mode possible
    • Other people have benchmarked Java 7 against JRockit 6 and seen same result as I did

    So the fact is, the new Java 7 JVM behavior is very different with our app, all other things being equal. The only resolution is to profile the code against the Java 7 VM, to discover where the slow points are in the code. (And perhaps at that point, it will be clear what the actual difference between Java 6 JVM and Java 7 JVM was/is).

    I appreciate everyone's comments, and apologize that I couldn't provide enough detail for a clear analysis/resolution.