Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[Explained] ART Runtime in Android 4.4(kitkat)

OP PradeepMurugan

23rd January 2014, 11:24 PM   |  #1  
PradeepMurugan's Avatar
OP Senior Member
Flag Karur
Thanks Meter: 258
 
222 posts
Join Date:Joined: Oct 2013
Donate to Me
More
What is ART?
ART stands for Android runtime which is a new runtime like Dalvik which is introduced experimentally in the 4.4 release. This is a preview of work in progress in KitKat that can be turned on in Settings > developer option.n 4.4 both runtimes are now available, Dalvik runtime (libdvm.so) and the ART (libart.so).The user can choose it from developer options.

Difference between Dalvik and ART

Dalvik
Dalvik runtime uses JIT(Just-In-Time) compilation to interpret Bytecode
Now lets understand the technical info and terms in the above sentence.

Compiler
A compiler is a program or set of programs that transforms source code written in a programming language (the source language) into another computer language

Bytecode
Bytecode also known as p-code (portable code), is a form of instruction set designed for efficient execution by a software interpreter

Interpreter
Interpreter is a program which translates the source code into computer/machine language[/quote]

JIT compliation
JIT (Just-In-Time) compliation interprets the bytecode into machine language at it's runtime (at the time when the apps are executed).



Now summing up all these Dalvik runtime does everything when the apps are executed. Now this is where we must discuss odexed and deodexed ROM. usually all stock ROMs released by OEMs are only odexed only due to this reason. odex means a part of the app is already compiled and it is written into dalvik VM(VM=Virtual Machine). and it runs at boot so while execution of apps JIT has to compile only the remaining part of the code when the apps is executed, this is why odexed ROM is faster than deodexed ROM.

But the disadvantage of odexed ROM is it cannot be edited/themed easily as a part of code is seperated in a separate file, and deodexing means the odex part of the file is put back into the apk/jar itself which makes editing/theming easy since the full code is packed inside a single file but it decreases speed because JIT has to compile full code when the app is executed


ART

ART uses AOT compilation to interpret bytecode.

I hope you can refer to dalvik paragraph to know about these technical terms.

what is AOT compilation
AOT (Ahead-Of-Time) is a method of compilation which compiles the code into machine language when the app is installed itself, means no compilation is done at the time of execution of app. This makes the apps launch speed amazingly fast.[/quote]


Advantages of ART over Dalvik

1. The apps launch speed is amazingly fast in case of ART since nothing is compiled at execution.
2. Boot speed is faster than dalvik since nothing is execued from dalvik partition as in case of odexed ROM in dalvik
3. Increases battery backup by reducing CPU work due to absence of compilation work on apps execution.
4. And finally it is a great reward to developers because most of developers are worried that odexed ROMs are faster than deodexed ROMs but they will deodex their ROMs since they heavily theme it. In case of ART whether the ROM is odexed or deodexed it doesn't matter, it compiles the full code into machine language on installation of apps. so even deodexed ROMs are as fast as odexed in ART

Some disadvantages of ART

1. Since ART precompiles apps on installation, it takes 10-20% more space upon installation than dalvik. But this can be simply solved by using apps like apps2sd/link2sd/gl2sd when your apps storage partition is full
2. One more is since it is only experimental feature now some apps are incompatible in ART which will be made compatible soon on their updates.

Here is the list of apps which are compatible and incompatible in ART.
http://www.androidruntime.com/list

Finally ART is one of the best feature that google brought up in android 4.4 (kitkat)
Last edited by PradeepMurugan; 27th November 2014 at 10:19 AM.
The Following 157 Users Say Thank You to PradeepMurugan For This Useful Post: [ View ]
24th January 2014, 09:51 AM   |  #2  
abhinav2hd's Avatar
Senior Member
Flag ✰✰✰✰✰✰✰
Thanks Meter: 843
 
365 posts
Join Date:Joined: Aug 2013
More
Nice One.. It is really helpfull.
The Following 3 Users Say Thank You to abhinav2hd For This Useful Post: [ View ]
24th January 2014, 11:59 AM   |  #3  
SDShukla's Avatar
Senior Member
Flag Banda
Thanks Meter: 149
 
146 posts
Join Date:Joined: Jan 2014
More
Thumbs up
Quote:
Originally Posted by PradeepMurugan

What is ART?


Difference between Dalvik and ART







Now summing up all these Dalvik runtime does everything when the apps are executed. Now this is where we must discuss odexed and deodexed ROM. usually all stock ROMs released by OEMs are only odexed only due to this reason. odex means a part of the app is already compiled and it is written into dalvik VM(VM=Virtual Machine). and it runs at boot so while execution of apps JIT has to compile only the remaining part of the code when the apps is executed, this is why odexed ROM is faster than deodexed ROM.

But the disadvantage of odexed ROM is it cannot be edited/themed easily as a part of code is seperated in a separate file, and deodexing means the odex part of the file is put back into the apk/jar itself which makes editing/theming easy since the full code is packed inside a single file but it decreases speed because JIT has to compile full code when the app is executed








Here is the list of apps which are compatible and incompatible in ART.
http://www.androidruntime.com/list

Finally ART is one of the best feature that google brought up in android 4.4 (kitkat)

Thanks Bro! For Info !
The Following 5 Users Say Thank You to SDShukla For This Useful Post: [ View ]
24th January 2014, 02:18 PM   |  #4  
bgos10's Avatar
Senior Member
Flag Gotham
Thanks Meter: 817
 
403 posts
Join Date:Joined: May 2013
Donate to Me
More
Thumbs up
Very well written
Last edited by bgos10; 24th January 2014 at 02:20 PM. Reason: removing quote
The Following User Says Thank You to bgos10 For This Useful Post: [ View ]
3rd February 2014, 01:24 AM   |  #5  
effry's Avatar
Senior Member
Flag Naples
Thanks Meter: 58
 
284 posts
Join Date:Joined: Mar 2011
More
Thanks for the info, really helpful! i have a question: When ART will be released in a "final" version will it be a big step ahead dalvik or just a little better than it? I mean, is this the right way to make android finally fast and smooth as ios or wp?
3rd February 2014, 03:10 AM   |  #6  
Junior Member
Thanks Meter: 3
 
17 posts
Join Date:Joined: Dec 2012
More
Great stuff, but do you mind explaining why some of the bigger apps, like Whatsapp didn't work on ART at first? What were they doing to cause such incompatibilities?
3rd February 2014, 03:38 AM   |  #7  
Moon.lSd's Avatar
Member
Thanks Meter: 20
 
77 posts
Join Date:Joined: Jul 2011
Quote:
Originally Posted by kinganu123

Great stuff, but do you mind explaining why some of the bigger apps, like Whatsapp didn't work on ART at first? What were they doing to cause such incompatibilities?

I don't know what about with Whatsapp, but for my app example, for the first time, some features do not work with ART, because of enforcement in JNI environment, which dalvik only gives warning, while art gives crash. We traced down the error stack and fix for both art and dalvik.

FYI: a recent commit from AOSP project had shown that ART now became default runtime in next Android version.
The Following 2 Users Say Thank You to Moon.lSd For This Useful Post: [ View ]
3rd February 2014, 05:13 AM   |  #8  
CTCaer's Avatar
Senior Member
Thanks Meter: 966
 
363 posts
Join Date:Joined: Mar 2012
Donate to Me
More
Good job on creating a great informative thread.

I want to point out some things to avoid confusion for new people in android:

*Odexed roms and Deodexed roms have exactly the same opening speed, booting time and performance, .
The only thing that is changed is the speed of the 1st boot time. Nothing else.
A deodexed rom having lower performance than an odexed is just placebo. The difference is just the odexes location of system apps.

To elaborate more on this matter, a fully odexed rom, the 1st time it will boot it will be very fast (like a normal reboot).
And normally the dalvik-cache folder will be empty because all odex files are near their source.

On a deodexed rom, the 1st time you power that device it will take a lot of time based on the cpu speed.
After creating the bootclass apps' odexes, you will see the screen that says how many remaining apps android is optimizing.
So after this is done, the performance, opening speed, boot time and everything is exactly the same as the odexed rom.

*The reason that OEMs put odexed roms is for 2 reasons, save storage space and zero to small extra time on 1st boot (or factory reset).

*And lastly, the only reason ART is faster on booting, is that it has faster app start up code and faster overall performance (because no interpreting to machine code is needed for every class/function/calculation etc, on app start up and while it's running).

Thanks again for making this guide
Last edited by CTCaer; 3rd February 2014 at 11:17 PM.
The Following 9 Users Say Thank You to CTCaer For This Useful Post: [ View ]
3rd February 2014, 04:22 PM   |  #9  
sachoosaini's Avatar
Senior Member
Thanks Meter: 111
 
547 posts
Join Date:Joined: Aug 2011
Donate to Me
More
A simple NOOB QUestion out of the heard
did this thing will be always be available for 4.4 or will it be ever be able to port for the lower end devices like oHTC Wildfire. Because those phones only got upto 4.2 they are laggy as hell and it even don't got any GPU. so ever ART will work with 2.3.7 roms ?
3rd February 2014, 04:24 PM   |  #10  
shut_down's Avatar
Senior Member
Flag Belgrade
Thanks Meter: 3,514
 
7,682 posts
Join Date:Joined: Sep 2010
More
Quote:
Originally Posted by sachoosaini

did this thing will be always be available for 4.4 or will it be ever be able to port for the lower end devices like oHTC Wildfire. Because those phones only got upto 4.2 they are laggy as hell and it even don't got any GPU. so ever ART will work with 2.3.7 roms ?

ART is a part of KitKat, Android 4.4. And it can't be downported. But not sure 100% in that.

The Following User Says Thank You to shut_down For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
art, art and dalvik, art better than dalvik, art runtime, what is art
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes