Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,739,099 Members 45,457 Now Online
XDA Developers Android and Mobile Development Forum

[Explained] ART Runtime in Android 4.4(kitkat)

Tip us?
 
PradeepMurugan
Old
(Last edited by PradeepMurugan; 28th January 2014 at 06:30 PM.)
#1  
PradeepMurugan's Avatar
Senior Member - OP
Thanks Meter 230
Posts: 218
Join Date: Oct 2013
Location: Karur

 
DONATE TO ME
Default [Explained] ART Runtime in Android 4.4(kitkat)

What is ART?
Quote:
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
Quote:
Dalvik
Dalvik runtime uses JIT(Just-In-Time) compilation to interpret Bytecode
Now lets understand the technical info and terms in the above sentence.
Quote:
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
Quote:
Bytecode
Bytecode also known as p-code (portable code), is a form of instruction set designed for efficient execution by a software interpreter
Quote:
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

Quote:
ART

ART uses AOT compilation to interpret bytecode.

I hope you can refer to dalvik paragraph to know about these technical terms.
Quote:
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
  • The apps launch speed is amazingly fast in case of ART since nothing is compiled at execution.
  • Boot speed is faster than dalvik since nothing is execued from dalvik partition as in case of odexed ROM in dalvik
  • Increases battery backup by reducing CPU work due to absence of compilation work on apps execution.
  • 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
Quote:
Some disadvantages of ART
  • 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
  • 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)
The Following 138 Users Say Thank You to PradeepMurugan For This Useful Post: [ Click to Expand ]
 
abhinav2hd
Old
#2  
abhinav2hd's Avatar
Senior Member
Thanks Meter 793
Posts: 336
Join Date: Aug 2013
Location: ✰✰✰✰✰✰✰
Nice One.. It is really helpfull.
The Following 3 Users Say Thank You to abhinav2hd For This Useful Post: [ Click to Expand ]
 
SDShukla
Old
#3  
SDShukla's Avatar
Senior Member
Thanks Meter 104
Posts: 122
Join Date: Jan 2014
Location: Banda
Quote:
Originally Posted by PradeepMurugan View Post
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: [ Click to Expand ]
 
bgos10
Old
(Last edited by bgos10; 24th January 2014 at 01:20 PM.) Reason: removing quote
#4  
bgos10's Avatar
Senior Member
Thanks Meter 680
Posts: 346
Join Date: May 2013
Location: Gotham

 
DONATE TO ME
Very well written
Hit. if you like my work




Follow US
If You Like My Work, You Can Also Donate To Me
My Work

The Following User Says Thank You to bgos10 For This Useful Post: [ Click to Expand ]
 
effry
Old
#5  
effry's Avatar
Senior Member
Thanks Meter 52
Posts: 261
Join Date: Mar 2011
Location: Naples
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?
Devices: Wildfire s CM7------> Xperia U -------> GALAXY NOTE 3
 
kinganu123
Old
#6  
Junior Member
Thanks Meter 2
Posts: 15
Join Date: Dec 2012
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?
 
Moon.lSd
Old
#7  
Moon.lSd's Avatar
Member
Thanks Meter 20
Posts: 71
Join Date: Jul 2011
Quote:
Originally Posted by kinganu123 View Post
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: [ Click to Expand ]
 
CTCaer
Old
(Last edited by CTCaer; 3rd February 2014 at 10:17 PM.)
#8  
CTCaer's Avatar
Senior Member
Thanks Meter 960
Posts: 362
Join Date: Mar 2012

 
DONATE TO ME
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
CTCaer

If you liked my post or it helped you just press the THANKS button.
Thank you.

Phone: ...

Tablet: Nexus 7 2013 (WiFi)

My released mod: **Elegant AOSP HD Collection** for all HDPI stock based Xperia phones and roms.

Kernel: **CTCaer Kernel for Ray** Light. Fast. Triple Buffering. More Total Ram. UKSM. Entropy.
The Following 9 Users Say Thank You to CTCaer For This Useful Post: [ Click to Expand ]
 
sachoosaini
Old
#9  
sachoosaini's Avatar
Senior Member
Thanks Meter 44
Posts: 304
Join Date: Aug 2011
Location: Narayangarh
Default 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 ?
 
shut_down
Old
#10  
shut_down's Avatar
Senior Member
Thanks Meter 3192
Posts: 7,216
Join Date: Sep 2010
Location: Belgrade
Quote:
Originally Posted by sachoosaini View Post
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: [ Click to Expand ]
Tags
art, art and dalvik, art better than dalvik, art runtime, what is art
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes