Java is often perceived as significantly slower and more memory-consuming than natively compiled languages such as C or C++. However, Java programs' execution speed have improved a lot, due to introduction of Just-In Time compilation[1] and mainly optimizations in the Java Virtual Machine itself introduced overtime.
Java Versions Performance History
Virtual Machine optimization techniques
Just-In-Time compilation
Template:Main article: JIT compiler
Adaptive optimization
Template:Main article: Adaptive optimization
Garbage collection
Template:Main article: Garbage collection (computer science)
Other optimization techniques
=Split bytecode verification
The JVM verifies all bytecode before it is executed (see Bytecode verifier). This verification is lazily performed : classes bytecodes are only loaded and verified when they are used, and not at the beginning of the program. However, as a the Java Class libraries are also regular Java classes, they must also be loaded when they are used, which makes that the start-up time of a Java program is often longer than for C++ programs, for example.
A technique named Split-time verification, first introduced in the J2ME edition of the Java platform, is used in the Java Virtual Machine since the [[Java version history#Java SE 6 (December 11, 2006)|Java 6 version]]. It split the verification of bytecodes in two phases [1]:
- Design-time : during the compilation of the class from source to bytecode
- runtime : when loading the class.
=Register allocation
Prior to [[Java version history#Java SE 6 (December 11, 2006)|Java 6]], allocation of registers was very primitive, which was a problem in architectures which did not have a lot of registers available, as x86 for example. An Optimization of register allocation was introduced in this version [2]. This allegedly leaded to approximately 60% performance gain in some benchmarks [3].
=Register allocation
See also
External Links
- Computer language shootout
- Comparison of Java Virtual Machines
- Mustang versus Tiger performance gain thread
- register allocation gain
- ^ A similar JIT mechanism is also used by the .NET framework virtual machine.