6

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 :)

igorgue
  • 17,884
  • 13
  • 37
  • 54
  • Where did you read that 450% increase in performance because of JIT? – Nate May 13 '10 at 16:48
  • it's all over the web: http://www.providingnews.com/android-2-2-450-faster.html – igorgue May 13 '10 at 17:04
  • JIT compiler is not faster than compiled code. It is only faster than interpreted code. Because JIT compiler can not spend as much time for optimizing as static compiler, the code is not as fast as normal compiled code. In addition there is the time needed for compiling each time the code is run. – PauliL May 25 '10 at 15:29

4 Answers4

5

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
  • 5,684
  • 21
  • 25
3

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
  • 2,548
  • 1
  • 22
  • 23
  • 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 May 13 '10 at 17:38
2

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
  • 5,590
  • 1
  • 25
  • 33
1

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
  • 2,366
  • 20
  • 26