The Revolution in Android Performance: The Enhanced Android Runtime (ART)

Christian Baghai
3 min readAug 31, 2023

--

The digital realm has evolved considerably over the years, and at the core of many of these innovations is the omnipresent Android operating system. In August 2023, Google revealed some groundbreaking improvements to the Android Runtime (ART), and these enhancements are already making waves in the tech community. This article delves deep into these changes and seeks to shine a light on their implications for the wider Android ecosystem.

Unveiling the ART: A Leap Beyond Dalvik

Before diving into the intricacies of the new ART, it’s crucial to appreciate its roots. The Android operating system originally employed the Dalvik process virtual machine. While effective in its prime, Dalvik had its limitations. Enter ART — a more advanced, efficient, and robust application runtime environment to propel Android into a new age.

Where Dalvik relied heavily on interpreting bytecode at runtime, ART takes this process a step further. It translates an application’s bytecode into native instructions that the device’s runtime environment can then execute. This change translates to faster app startup times, heightened performance, reduced memory consumption, and enriched debugging support.

ART’s Dual Compilation Approach: AOT & JIT

A standout feature of ART is its ability to support both ahead-of-time (AOT) and just-in-time (JIT) compilation. This dual approach has numerous advantages:

Ahead-of-time Compilation (AOT): With AOT, the translation of an app’s bytecode into native code happens either when the app is installed or during system updates. This proactive approach eradicates the need for interpretation during runtime, thereby speeding up app startup times considerably.

Just-in-time Compilation (JIT): Contrasting AOT’s preemptive nature, JIT converts bytecode into native code as and when the app runs. It paves the way for adaptive optimization, ensuring that only necessary code components get translated, optimizing storage space and efficiency.

Enhanced Memory Management with ART

An ever-present challenge for runtime environments is the efficient management of memory. With applications becoming more intricate and demanding, ensuring optimized memory use without compromising on performance is paramount.

ART’s response to this challenge is its revamped garbage collection (GC) approach. In basic terms, garbage collection is about reclaiming memory that apps no longer need. ART has elevated this process:

1.Concurrent Design: Most of the GC work now occurs simultaneously with app execution. This parallel operation leads to a single, brief pause to finalize memory reclamation. It’s a major shift that has minimized the adverse impacts of garbage collection on app responsiveness and speed.

2. Concurrent Copying: This method reduces background memory usage and fragmentation by shifting live objects to a different memory region, all while maintaining their relative sequence. This not only aids in efficient memory allocation but also speeds it up.

The Magic of Profile-guided Optimization (PGO)

If ART’s memory management was its defensive strategy, then profile-guided optimization (PGO) is its offensive play. PGO is akin to a runtime detective — it collects data on app behavior, noting which methods see frequent use, which code paths are often taken, and which object types dominate. Once this data is compiled, it guides the optimization of the native code.

Thanks to PGO, the compiler gets tactical: unnecessary code is trimmed, frequently used code is inlined, and the overall code layout gets an efficiency makeover. PGO also enhances code locality, placing oft-used code segments close in memory. The upshot? A sharp drop in cache misses and a noticeable boost in performance.

A New Dawn for Android Performance

Google’s announcement was more than just tech rhetoric. Claiming that the new ART improvements can slash app startup times by up to 15%, augment execution speed by as much as 10%, and curtail memory usage by a staggering 20% isn’t minor. It represents a transformation in how Android devices function, elevating user experiences and opening doors for app developers to create richer, more dynamic applications.

--

--