开发者

How a JIT compiler helps performance of applications?

开发者 https://www.devze.com 2022-12-30 18:33 出处:网络
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 comp开发者_运维百科iled cod

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 comp开发者_运维百科iled 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 :)


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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消