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 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.
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