Dalvik and ART for Android

Without wishing to get involved in a debate over the merits of individual operating systems, one of the valid criticisms of Android is that it is relatively sluggish compared with other operating systems running in similar hardware. Comparing devices running iOS or Windows Phone with Android, in order to get the same smooth, responsive interface with the Android device you typically need more horsepower under the skin.

Part of the reason for this is because Android is a sophisticated operating system and is doing more in the background that we, the user, can see. Another reason is how applications are launched on Android devices.

art-and-dalvikCurrent versions of Android use a Java run time designed using the JIT, or Just In Time, ideology. Long term Android users may remember that when Android moved from 2.1 to 2.2, Google changed how the devices compiled code and at the time, the JIT Dalvik system was significantly quicker than what we had before. Since then, the stock Dalvik run time is little changed, although various manufacturers have tuned their own run time to improve performance.

Applications are stored in a partially-compiled format on the device, which occupies less application storage space. That’s why it’s possible to send applications from one Android device onto a completely different target Android device; when you run the application on the new device, it compiles itself for the host hardware.

This means that when an application is launched, the operating system must first compile the code before it can run it.

This is one advantage of Android to date: applications are more or less universal, whereas going back in time to say Windows Mobile (not Windows Phone), developers had to compile and release different versions of the applications depending on the processor being used.

The disadvantage to the JIT system is that when we launch an application, the process is harder on the device. It works the processor harder so things take longer and use more battery. The Android operating system does what it needs to do whilst looking smooth and polished to the user.

With the release of Android Kit Kat running on Qualcomm Snapdragon processors (currently the 2013 Nexus 7 tablet and Nexus 5) there’s a Java Run Time mode hidden away in Developer Settings. You can switch from the current Dalvik mode to the new Android Run Time, or ART.

If you do this, the device reboots and compiles all the apps installed. If you have a good number, this will take several minutes.

Android Run Time pre-compiles applications for your hardware. You won’t be able to share an application from one device to another, but instead, the applications launch much faster. Not only applications launch quickly, but they’ll also use less power when then do.

The speed difference is difficult to assess. Right after the reboot, my Nexus 4 is more responsive but over a period of time it starts to feel very much the same regardless of the run time I’m using. Now, I don’t have many applications on my device and perhaps this makes a difference, but for me there’s no discernible difference.

It’s also true that although the Nexus 4 is not the most recent Android device, it’s still a ¬†powerful device with plenty of memory. The new Android Run Time will likely make a bigger difference on those lower powered devices.

ART is still in the experimental stage and Google are evolving it; the update from Android 4.4 to 4.4.1 has some improvements to ART under the skin. I suspect that we’re going to hear a lot more about ART in the coming year.

, , , , ,