Are Java 6's performance improvements in the JDK, JVM, or both?

后端 未结 4 1338
[愿得一人]
[愿得一人] 2021-01-20 04:18

I\'ve been wondering about the performance improvements touted in Java SE 6 - is it in the compiler or the runtime? Put another way, would a Java 5 application compiled by J

相关标签:
4条回答
  • 2021-01-20 04:40

    Its almost 100% the runtime. While it is possible for some basic compilation tricks to make it into the Java compiler itself, I don't believe there are any significant improvements between Java 1.5 and 1.6.

    0 讨论(0)
  • 2021-01-20 04:55

    There's been a lot of new improvements and optimization in the new java virtual machine. So the main part you'll see improved performance is while running java with the version 6 jvm.

    Compiling old java code using the Java 6 JDK will probably yield more efficient code, but the main improvements lie in the virtual machine, at least that's what I've noticed.

    0 讨论(0)
  • 2021-01-20 05:01

    javac, which compiles from Java source to bytecodes, does almost no optimisation. Indeed optimisation would often make code actually run slower by being harder to analyse for later optimisation.

    The only significant difference between generated code for 1.5 and 1.6 is that with -target 1.6 extra information is added about the state of the stack to make verification easier and faster (Java ME does this as well). This only affects class loading speeds.

    The real optimising part is the hotspot compiler that compile bytecode to native code. This is even updated on some update releases. On Windows only the slower client C1 version of hotspot is distributed in the JRE by default. The server C2 hotspot runs faster (use -server on the java command line), but is slower to start up and uses more memory.

    Also the libraries and tools (including javac) sometimes have optimisation work done.

    I don't know why you are finding JDK 6 slower to compile code than JDK 5. Is there some subtle difference in set up?

    0 讨论(0)
  • 2021-01-20 05:06

    I have not heard about improvements in the compiler, but extensive information has been published on the runtime performance improvements.

    Migration guide:

    http://java.sun.com/javase/6/webnotes/adoption/adoptionguide.html

    Performance whitepaper:

    https://www.oracle.com/java/technologies/javase/6performance.html

    0 讨论(0)
提交回复
热议问题