Will we get Java 6 performance boost if bytecode was compiled in 1.4

I assume that there is a big performance difference between Java 1.4 and Java 6 after changing this document .

My question is, will the Java 6 runtime still have its magic when the bytecode that it should execute was compiled in 1.4?

Some prerequisites for "why the question?" here .

+7
source share
4 answers

Yes, since most of the optimizations are performed during the execution of the JVM, the compiler does very little with respect to optimizations. That way, code compiled with the old Java compiler will still benefit from the new JVM.

However, some optimizations are performed during compilation, such as replacing consecutive String concatenations with StringBuilder .

+9
source

As Tomash Nurkevich notes, most of the optimization is done by the JIT compiler, and you should see the performance benefits by running java 6 instead of java 1.4. However, this does not guarantee that you will get the best results. You can skip the benefits if you use slower (older) options for data structures. e.g. StringBuffer instead of StringBuilder, Vector instead of LinkedList, Hashtable instead of HashMap, etc.

You may also consider compiling with the -deprecated flag for javac. You will probably want to replace obsolete methods, as they usually mean that there is a better alternative to achieve the same goal.

+2
source

Almost all optimizations in java occur in jit and therefore depend only on the version of jvm that runs the application. The javac bytecode compiler simply emits the most direct bytecodes. I do not think that at this stage there are any optimizations except, perhaps, for concatenating strings using StringBuilder / StringBuffer .

Java 6 and above can use the faster and simpler byte code of the verifier for classes compiled with the target version 6. The javac compiler creates additional information about the data types in each slot in the stack that the verifier should check. In previous versions, the verifier was supposed to infer these types, which are more complex. This change will speed up the loading of classes and will not have any effect on the actual execution of the bytecode.

I think another change in the bytecode in version 5 or 6 was that the constant pool in the class file can refer to classes and interfaces. Again, this probably only affects class loading.

+1
source

Not only will there be tremendous performance, but even between versions of Java 6 there are big differences. I tracked small releases of Java 6 over an 18-month period and saw 15-20% acceleration from that.

Java 7, by the way, is the preferred production version - is there a reason why you do not want to switch to this version?

Oh, and the last. If you need to prove the benefits of management, you should learn a lot about the performance of Java applications. I have an article in the upcoming May / June issue of the Oracle Java Journal, which is the real 101 if you need it. This is a very slippery topic, so you have to read a lot, or you can get very misleading figures.

0
source

All Articles