Saturday, February 5, 2011

Performance impact of Java class files generated with "-target 1.5" running on a 1.6 VM?

After migrating my whole setup from Java 1.5 to 1.6 (J2EE, Tomcat) a couple of months ago, I just realized that Maven is still configured to generate class files targeted for 1.5 via Sun's javac parameter "-target 1.5". Can I expect any performance boosts when changing "-target 1.5" to "-target 1.6"?

  • I don't see why there'd be a performance difference. There's no major differences between the class format of 1.5 and 1.6. If nothing else changes specifying the target will change the classversion id in the generated classes.

  • It shouldn't make much difference. 1.6 files can have stack map/table structures that improve bytecode verification speed (Apache Harmony just uses a smarter algorithm).

    If you were to go to 1.4 the initial loading of a class constant would be slightly slower, but that's irrelevant given how long a class takes to load (a new form of the ldc bytecode replaces Class.forName, but the result was stored in a static field.)

    In general it doesn't matter. The runtime compiler is the important bit and that can pretty much generate the same machine code. In the past there have been made to javac to reduce the optimisation it does so as not to mangle the code for the runtime compiler, but that is independent of the -target flag.

    Kjeld : I think I'm going to change it for the next update. Shouldn't hurt though and feels more consistent...
  • Java 1.6 uses a different class-file-format, that simplifies the process of the bytecode-verification. So startup-times should improve a little, if you use the new class-file-format.

    From Mnementh

0 comments:

Post a Comment