Java performance

This is an old revision of this page, as edited by Hervegirod (talk | contribs) at 13:12, 6 January 2007 (Created page with 'Java is often perceived as significantly slower and more memory-consuming than natively compiled languages such as [[C (programming language)|...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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

  1. ^ A similar JIT mechanism is also used by the .NET framework virtual machine.