Search code examples
javaperformancejava-7bytecode

Are there any known runtime performance issues Compiling to Java 6 bytecode with Java 7


Working on migrating our application to Java 7. We see runtime performance issues compiling Java 6 bytecode with Java 7. Is that expected? What are the downsides/benefits of doing that?

We have a web application that has a SOAP interface. In our regression testing we shoot SOAP messages at it and get SOAP messages back. We use Groovy to help manage this testing.

To be more explicit, we are compiling with

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>

with a Java 7 SDK. Doesn't this compile java 6 byte code? (With Java 7)

Some examples of things I'm looking for

Given that HashMaps in jdk1.6 and above cause problems with multi=threading, how should I fix my code

https://www.servoy.com/forum/viewtopic.php?f=6&t=19140

For our testing service we simulate users hitting our web service. Reducing the number of threads to 8 instead of 20 in our tests significantly decreased overall runtime. This was based on the HashMap article above. Can anyone else see another reason that there would be decreased performance with multithreading? In java 6, we ran with 20 threads and it was faster.


Solution

  • We see runtime performance issues compiling Java 6 bytecode with Java 7. Is that expected?

    No. It is not expected. It is possible ... but I wouldn't have predicted it, and I can't think of an obvious explanation.

    What are the downsides/benefits of doing that?

    I can think of no real benefits to your problem (migration) of compiling code using Java 7 tools and setting to "-target" to "1.6". I would go straight to compiling for the Java 7 platform.

    Certainly, there is nothing to be gained from trying to figure out why the code apparently runs slower. It might be a real effect, or an illusion; e.g. an artefact of the way you are doing your benchmarking / performance measurement. But either way, it doesn't tell you anything about what will happen if you compile for Java 7 and run on Java 7 ... which is where you are trying to get to.


    In general, you would not expect performance to be slower in a newer release of Java. However, there are factors that could cause performance characteristics to change. For example:

    • Changes in the JIT compiler might in theory cause certain atypical applications to run slower.

    • Changes in JIT compilation strategy might result in code being JIT compiled later ... which could affect performance during startup / warmup. (A benchmarking should be designed to compensate for that ...)

    • Changes in heap organization / garbage collection algorithms could require tuning / retuning.

    And so on.