Android’s New Runtime (ART) – Quick Overview
The new Android Runtime (ART) has been lurking under the covers as an experimental developer option (on select android phones) since Android KitKat 4.4. Android Lollipop 5.0 makes ART the default runtime. Let’s take a quick look at what impact this will have on our apps.
Prior to Lollipop, Android used the Dalvik runtime. Dalvik is a Just In Time (JIT) runtime which means that an application’s bytecode is not converted to executable machine code until it is launched. Even then, only the parts of the application that are needed are converted.
Lollipop’s runtime is the new ART, which trades JIT for Ahead of time Compilation (AOT). This means that all applications are converted to machine code before they are launched, leading to much faster load times. Also, with the older JIT, the runtime performed some class and method verification at runtime that will have already taken place with AOT, further reducing the execution overhead and increasing performance.
The actual conversion from bytecode to machine code now takes place during the installation of an app. This leads to longer install times and a larger application footprint (because of the storage of machine code), but its all for the sake of better performance later.
Another dramatic change with the ART has to do with how the runtime handles Garbage Collection (GC). ART reduces the number of times the runtime pauses for GC, and also has reduced the amount of time GC runs for a foreground application. For example, Google claims that prior to ART, for a particular time period you may have seen 2 pauses for GC totaling about 10ms of time. With ART, you may see 1 pause for a total time of 2ms for the same time period, which will have much less impact on the performance of an application. Note that ART defers a full GC run until the phone is locked or user interaction is not indicated.
ART is designed to support a mix of AOT, JIT, and interpreted paradigms. The ART runtime has cross platform support for ARM, x86, and MIPS architectures, and it introduces full 64-bit support for ARMv8, x86-64, and NIP 64 architectures.