views:

427

answers:

5

I just read that Android has a 450% performance improvement because it added a JIT compiler, I know what JIT is, but I don't really understand why is it faster than normal compiled code? or what's the difference with the older approach from the Android platform (the Java like run compiled bytecode).

Thanks!

EDIT: This is hugely interesting, thanks!, I wish I could pick every answer as correct :)

+2  A: 

The JIT compiler knows about it's system, it can use that knownledge to produce highly efficient code compared to bytecode, and rumors go it can surpass pre-compiled programs.

That's why it can go faster than the traditional system of java, where the code was run as bytecode only, which Android used, too.

LukeN
+3  A: 

First a disclaimer, I'm not at all familiar with Android. Anyway...

There are two applications of JIT compilation that I am familiar with. One is to convert from byte-codes into the actual machine instructions. The second is Superoptimisation.

JIT bytecode compilation speeds things up because the bytecodes are only interpeted once, instead of each time it is executed. This is probably the sort of optimisation you are seeing.

JIT superoptimsation, which searches for the truly optimal set of instructions to implement a programs logic, is a little more esoteric. It's probably not what your talking about, though I have read reports of 100% - 200% speed increases as a result.

torak
+3  A: 

The VM needs to turn compiled byte code into machine instructions to run. Previously this was done using an interpreter which is fine for code that is only invoked once but is suboptimal for functions that are called repeatedly.

The Java VM saw similar speedups when asa JIT-versions of the VM replaced the initial interpreter versions.

Christopher Barber
To clarify, Dalvik, the "Java-like" VM on Android was a bytecode interpreter. In Android 2.2, Google has created a bytecode to machine code compiler. For code that the overhead of doing the native compilation is less than the cost of executing it, Dalvik with JIT should give a noticeable performance improvement.
Yann Ramin
+1  A: 

read this article - http://www.ibm.com/developerworks/java/library/j-jtp12214/

Pangea
+1  A: 

Besides compiling java code to native code, which could be done with a compiler too, a JIT does optimizations, that you can only do at runtime.

A JIT can monitor the applications behavior over time and optimize those usage patterns that really make a difference, even at the expense of other branches in the execution path of the code, if those are less frequently used.

Mariano Kamp