Click here to Skip to main content
15,881,880 members
Articles / Mobile Apps / Android
Article

Android New Runtime ART

Rate me:
Please Sign up or sign in to vote.
3.70/5 (9 votes)
13 Jun 2014CPOL3 min read 14.6K   12   7
New Runtime in Android operating system Kit Kat version (Android 4.4)

Introduction

Google has introduced “ART” a new Android runtime experimentally in the 4.4 release (Kit Kat).

Description

Google has been continuously introducing new features from version to version. In Kit Kat Android version 4.4, it has improved a performance of Android application execution by introducing new experimental android runtime “ART”.

Android apps are deployed in Dalvik bytecode, which is portable, unlike native code. To run the app on a device, the code has to be compiled to machine code.

Kit Kat is the first Android operating system version which has two Android runtimes variants

  • Dalvik
  • ART

Dalvik works based on "JIT" Just In Time compilation. When each time you run an app, the part of the code required for its execution is going to be compiled to machine code at that moment. As you progress through the application, additional code is going to be compiled and cached. System can reuse the code while the application is running. JIT compiles only a part of the code, so it has a smaller memory footprint and uses less physical space on the device.

ART works like compiles the intermediate language --> Dalvik bytecode --> into a system-dependent binary code. Complete code of the application will be pre-compiled during install once, thus removing the lag that is seen when we open an application on our device. With no need for JIT compilation, the code should execute much faster compared to Dalvik runtime.

Other than the speed increase, using of an ART can provide an most important secondary critical benefit for mobiles / portable devices. ART runs application machine code directly (i.e, native execution), it doesn't utilize CPU as hard as just-in-time code compiling on Dalvik. Less CPU usage results in less battery drain, which is a big plus for mobile devices in general where lot of user looking while choosing mobile to buy.

Major drawback with ART is generated machine code (i.e., Native code) requires more space compared to the existing bytecode. The code is pre-compiled at install time, so the installation process takes a bit longer. Furthermore, it also corresponds to a larger memory footprint at execution time. This means that fewer applications run concurrently. Now a days memory is much cheaper in cost and even on low-end devices have more enough RAM and ROM , so ART is a logical step forward for new Android versions.

This is a preview of work in progress in KitKat that can be turned on in Settings -> developer options -> Select runtime -> Use ART -> ok to reboot as shown.

Settings

developer options

Select runtime

 Use ART

After reboot when the mobile is booted up, Android mobile will run with new runtime ART. As an Android developer each time when I made a little change, I wanted to test installed new application instance on the device. As stated earlier ART uses Android One Time compilation, which prolongs the install times of applications because the Dalvik bytecode gets compiled to machine code. Each time for deploying new version of the application on to my testing mobile device needs to wait for additional time to pass so that the app optimizes for the ART runtime. This causes a significant delay in the deployment process. In my application development process, one of our larger projects jumped from 27 sec to 39 sec.

Points of Interest

Coding wise, it's the same for normal Android application development with both runtimes. My quick overview of the results observed with new runtime ART on Google's Motorolo Android device "Moto G" is increased speed in CPU arithemetic operations, RAM operations and storage operations which results in overall 20% average increase in the speed.

While playing games, I also observed the smoothness and touch response improved very much.

History

  • 11th June, 2014: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
fulloflove24-Oct-14 21:47
fulloflove24-Oct-14 21:47 
Apart from the old news from every magazines, the remaining part "Furthermore, it also corresponds to a larger memory footprint at execution time" is completely incorrect.

ART uses more flash ROM space to trade with RAM and CPU usage. In normal JIT, both the bytecode and the compiled binary must be present in RAM, not including the significant amount of memory for the JITer itself and possibly some more for optimized version of tight loops. Those combine into a bunch much larger than only the optimized binary in case of ART. More on this here
Questionbeware of phone incompatibility risk Pin
RabinDl23-Jun-14 21:36
RabinDl23-Jun-14 21:36 
AnswerRe: beware of phone incompatibility risk Pin
Member 1058259724-Jun-14 14:55
Member 1058259724-Jun-14 14:55 
GeneralMy vote of 5 Pin
Abinash Bishoyi22-Jun-14 23:40
Abinash Bishoyi22-Jun-14 23:40 
Generalby using this article I to tried in moto e few games performance has been increased ............ Pin
raju k21-Jun-14 3:10
raju k21-Jun-14 3:10 
GeneralMy vote of 1 Pin
Member 376270219-Jun-14 11:41
Member 376270219-Jun-14 11:41 
GeneralMy vote of 1 Pin
oliver.stockleySSP17-Jun-14 5:20
professionaloliver.stockleySSP17-Jun-14 5:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.