Since its early release versions, such as “Cupcake” (1.5) and “Donut” (1.6), to the current “KitKat” (4.4), Android has maintained a layer-based architecture. Starting from the bottom, it includes: “Linux Kernel”, “Libraries and Android Runtime”, “Application Framework”, and “Application” (Figure 1).
Figure 1 Android KitKat (4.4) experimentally introduced a new runtime called “ART”
Each Android app runs on its own virtual machine (VM), which is called “Dalvik”. In Android 4.4, along with Dalvik, Google experimentally introduced a new Android Runtime called “ART”. Android users can easily switch between Dalvik and ART in “Settings” / “Developer options” / “Select runtime”, in which a dialog (Figure 2) will show. ART is currently released for experiment and tryout purposes. At this time you may see issues and even app crashes. Active development and optimization works are still under way. But Google makes it very clear: ART will eventually replace Dalvik as the Android Runtime.
Figure 2 Android KitKat allows users to switch between Dalvik and ART runtimes
In the following sections, we will take an insider look at the differences between the two Android Runtimes.
Android apps come in the .apk file format, with Java classes converted into DEX bytecode. The DEX bytecode format is independent of device architecture and needs to be translated to native machine code to run on the device. This is the same for both the ART and the Dalvik runtimes.
The most significant change from Dalvik to ART is that Dalvik is based on Just-in-Time (JIT) compilation, while ART is based on Ahead-of-Time (AOT) compilation.
With the Dalvik JIT compiler, each time when the app is run, it dynamically translates a part of the Dalvik bytecode into machine code. As the execution progresses, more bytecode is compiled and cached. On the other hand, ART is equipped with an Ahead-of-Time compiler. During the app’s installation phase, it statically translates the DEX bytecode into machine code and stores in the device’s storage. This is a one-time event which happens when the app is installed on the device.
The most important benefit of ART runtime over Dalvik runtime is that the app runs faster on ART. Because DEX bytecode has been translated into machine code during installation, no extra time is needed to compile it during the runtime. The app starts faster as well when launched with ART for the same reason.
Because Dalvik requires extra memory for JIT code cache, an app occupies a smaller memory footprint when it runs on ART.
With Dalvik runtime, the JIT compilation is CPU bound. Because of AOT compilation, ART frees the CPU from translating DEX bytecode to machine code during the app’s execution, thus reducing energy consumption. Using ART leads to a longer battery life, which is the time interval when a battery recharging is needed.
Because the AOT compiler translates DEX bytecode into machine code during the app installation, an app takes longer to install on a device with ART runtime. Considering the benefits of faster execution and shorter launch time we discussed in the previous section, this extra time which happens only once during the app’s installation is well worth it.
With ART runtime, the AOT compiler translates the app’s DEX bytecode into machine code and stores it in the device’s storage. The pre-compiled binary occupies more space than the DEX bytecode. Thus results in a larger storage footprint comparing with Dalvik runtime.
To this point we have introduced the new ART runtime for Android. We also discussed its benefits and compromises, centralizing in its Ahead-of-Time compilation and performance improvement. Currently released for preview and still under active development and optimization, at this point of time we cannot provide a quantitative conclusion on how much performance gained by switching to ART Runtime. One thing for sure is ART will replace Dalvik as the Android runtime on the x86 based devices.
“Meet ART, Part 1: The New Super-Fast Android Runtime Google Has Been Working On In Secret For Over 2 Years Debuts In KitKat” http://www.androidpolice.com/2013/11/06/meet-art-part-1-the-new-super-fast-android-runtime-google-has-been-working-on-in-secret-for-over-2-years-debuts-in-kitkat/
*Other names and brands may be claimed as the property of others.
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.
Notice revision #20110804