Along with Android 4.4 KitKat, launched at the end of last year, Google decided to ship the new version of the virtual machine of its mobile operating system, the ART (Android Runtime), which promises to make running apps much more efficient. With the official launch of Android L approaching, it has already been announced that ART will exit its testing phase and effectively replace the virtual machine Dalvik. In this article, I explain in detail what ART is, how it will work and also its advantages and possible disadvantages.
What is ART or Android Runtime?
To understand the benefits of the new runtime ART, we have to resort to technical details of the two systems. Applications running on Android today use a virtual machine (VM) called Dalvik, created by Dan Borstein since the first version of the system. Basically, the programs are written in Java and then converted to machine code called bytecode – an intermediate step between the source code and the code readable by the hardware. At this stage, the code is not associated with any specific machine code and can be converted to run on several different architectures (portability). Finally, the MV Dalvik translates the bytecode in code readable by the machine in question, code that is actually executed by the main processor. This translation (compilation) occurs during the execution of the application, which gives the name to the technique used for this: JIT (Just In Time).
THE ART, in turn, was designed to use a compilation technique called AOT (Ahead Of Time). Its main difference from Dalvik is that it occurs before of application execution – not during, like JIT – which eliminates this step during runtime. With this, it is expected an increase in execution speed of up to 2 times in relation to Dalvik, reducing the perception of delay.
As an illustration, a benchmark graph of a simple value ordering algorithm follows (quicksort) executed on an Android device under ART (red), Dalvik (blue) and Java Native Interface (orange), a technique that allows a Java program to access applications and libraries written in a lower level language, such as C / C ++ / Assembly.
Advantages and disadvantages of ART (Android Runtime)
Apps will get faster, but also take up more memory
This is a consequence of the very nature of the next Android virtual machine: if an application is kept ready to run, of course it will take up more space. Since the app’s code is compiled when you install it, and is then kept in memory instead of compiling whenever you open it, it means it will take up extra permanent space. This can cause problems for low memory devices, and higher speed always comes with a price. It is still early, however, to know the concrete consequences of this fact for input devices, such as those of the Android One series or the Moto E.
ART will save battery
Another obvious consequence of the way ART works: if all the applications on your phone are pre-compiled, the processor will have to work less each time you open them, which leads to less battery consumption. The downside is that every time you start your device for the first time, it will take a lot longer, especially if it has a lot of bloatware. The same goes for when you first open a new app. After that, however, everything will be faster.
ART is faster than you think
The current version of ART running on Android L is obviously an option for developers. When Google announced the final move to ART at Google I / O, it was stated that the new virtual machine will be twice as fast as Dalvik, showing a benchmark test as evidence:
But what you may not know is that Google has also said that other tests have shown that ART can be three times faster than Dalvik. We still don’t know how fast the final version of the machine will be, but Google’s strategy of announcing speed and then surprising everyone with an even faster ART seems plausible.
Have you been using ART in KitKat? What are your impressions?