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

 ̄綄美尐妖づ 提交于 2019-12-31 01:55:08

问题


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 JDK 6 see an improvement run under JSE 5 (indicating improved compiler optimization)? Would a Java 5 application compiled by JDK 5 see an improvement run under JSE 6 (indicating improved runtime optimization)?

I've noticed that compiling under JDK 6 takes almost twice as long as it did under JDK 5 for the exact same codebase; I'm hoping that at least some of that extra time is being spent on compiler optimizations, hopefully leading to more performant JARs and WARs. Sun's JDK info doesn't really go into detail on the performance improvements they've made - I assume it's a little from column A, and a little from column B, but I wonder which is the greater influence. Does anyone know of any benchmarks done on JDK 6 vs. JDK 5?


回答1:


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:

[http://java.sun.com/performance/reference/whitepapers/6_performance.html]




回答2:


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?




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/93049/are-java-6s-performance-improvements-in-the-jdk-jvm-or-both

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!