Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday 3 February 2015

Dalvik or ART : which Runtime is Better on Android

If you have an Android phone running KitKat (4.4), you can get a performance and battery life boost by switching from the outdated Dalvik runtime. The runtime on your device is the sub-system that determines how applications and tasks run. The ART runtime is set to replace Dalvik. Although the Dalvik runtime did a decent job, it was still a major cause of bottlenecks on the system. Why? Because Dalvik is a Just-In-Time compiler. This type of compiler ran code at the moment it needed it.
The newer ART runtime is an Ahead-of-Time compiler that processes application instructions before they are needed. This is much more efficient both for performance and battery life. 
The major difference between ART and Dalvik is the way they execute the apps. Based on JIT (just in time) compiler, Dalvik runs the command only when needed. On the other hand, ART features an AOT (ahead of time) system that processes code in advance to deliver a relatively smoother user experience.

You can choose to use it by going to "Settings> Developer Options> Select Runtime" and choosing ART. 
 

ART vs Dalvik
Dalvik is based on JIT (just in time) compilation. It means that each time you run an app, the part of the code required for its execution is going to be translated (compiled) to machine code at that moment. As you progress through the app, additional code is going to be compiled and cached, so that the system can reuse the code while the app is running. Since JIT compiles only a part of the code, it has a smaller memory footprint and uses less physical space on the device. 

ART, on the other hand, compiles the intermediate language, Dalvik bytecode, into a system-dependent binary. The whole code of the app will be pre-compiled during install (once), thus removing the lag that we see when we open an app on our device. With no need for JIT compilation, the code should execute much faster.

Except for the potential speed increase, the use of ART can provide an important secondary benefit. As ART runs app machine code directly (native execution), it doesn't hit the CPU as hard as just-in-time code compiling on Dalvik. Less CPU usage results in less battery drain, which is a big plus for portable devices in general.  


Let's take a quick overview of the results of their benchmarks:

  • increased speed in CPU floating operations by approx. 20%
  • increased speed in RAM operations by approx. 10%
  • increased speed in storage operations by approx. 10%
  • CPU integer operations - slight advantage goes to Dalvik 


Conclusion
Personally, I saw an improvement in the speed and smoothness of scrolling in apps. ART makes the UI feel more responsive. At this time, ART is not fully optimized. I expect even better results in the future, after Google acquires more feedback and makes additional optimizations. As I see it, end users will definitely benefit from the switch, once ART matures and gets more stable. However, developers, who frequently deploy apps, will feel more intensively the negative impact of prolonged install times.


No comments:

Post a Comment