If you’re an Android user, you might have seen or heard the terms ART and Dalvik before. If you’re not sure what they are, read this simple explanation and find out if they’re important to you.
What are Dalvik and ART?
Dalvik is a virtual machine designed to run applications and code written in Java. It’s hard to explain this without getting very technical but suffice to say it’s how apps are able to work on your Android operating system. Any application written in Java code needs a Java Virtual Machine to run. Dalvik is a mobile version of a Java Virtual Machine.
When Android released the KitKat operating system in 2013, it introduced a replacement for Dalvik called ART. ART stands for Android runtime. Two years went into developing ART and its capabilities are vastly different to Dalvik
The idea is that Android devices using ART will perform better than those using Dalvik. ART’s existence and it’s improved performance is made possible by the fact that modern smartphones are significantly more advanced than the first generation of Android devices.
When ART was included in the release of Android 4.4 KitKat, it was still experimental. Google’s Android developers wanted to get feedback on it from users and other developers, in order to make further improvements.
The ‘Developer options’ menu on Android
At the time it was not introduced as standard but instead as an extra for Android users, essentially allowing them to activate it by going to ‘Settings’, then ‘Developer options’, ‘Select runtime’ and, finally selecting ‘ART’.
ART was optional in earlier versions of the Android OS
You may notice that your phone’s menu doesn’t offer ‘Developer options’. This menu needs to be activated by tapping 7 times on your phone’s build number. When you have done that you will see a message saying that you are now a developer, and you will have the extra menu options.
In 2014, with the release of Android 5.0 Lollipop, ART became the default runtime, finally replacing Dalvik.
What’s actually different between ART and Dalvik? AOT vs. JIT
Just-in-time compilation (JIT)
Before apps can be run on Android, the code behind them must be compiled into machine code (which is basically what ART and Dalvik are there for).
Dalvik uses JIT, or just-in-time compilation. What that means is whenever you use an app; the code it needs to run is compiled, but only that piece. If you use another part of the app, more code will be compiled. The compiled code is then cached so that it can be reused while you are still running the app. Code is compiled as it is needed.
This just-in-time method means that Dalvik uses relatively little memory to perform its tasks, which was ideal for earlier Android devices that had less memory.
Memory space is less of a problem for today’s devices, which is what lead to the development of ART.
Ahead-of-time compilation (AOT)
ART collects the code into a system-dependent binary by pre-storing all of it during installation. This means it only ever has to be compiled once. Because of this, apps will run faster on Android devices using ART because there’s no need for the code to be compiled each time they are required to run.
The other upside of ART is that it uses native execution, which means that it runs app machine code directly. The beneficial result of native execution is that it places less strain on the CPU than Dalvik’s JIT compiling. The lower CPU usage should translate into longer battery life.
There are a couple of trade-offs for this improved performance. One is that the compiled code takes up more space in your device’s memory. The second is that because the code is compiled during installation, it takes longer to install apps.
Exactly how big is the difference in performance between Dalvik and ART?
Luckily for us, the guys at Android Police ran some tests comparing the two.
They found that ART gave:
- around 20% increased speed on CPU floating operations
- around 10% increased speed in RAM operations
- around 10% increased speed in storage operations
- slightly worse performance in CPU integer operations than Dalvik
Of course the average Android user isn’t likely to get that technical, which leads us to the big question…
Should you care about Dalvik and ART?
The short answer is: not really
Unless you are a developer, the performance difference we are talking about is hardly noticeable. On the other hand, maybe you can impress someone at a party with your new knowledge.