Android Runtime

Last updated

ART
Developer(s) Google
Repository android.googlesource.com/platform/art/
Written in C, C++
Operating system Android
Type Runtime environment
License Apache License 2.0 [1]
Website source.android.com/docs/core/runtime   OOjs UI icon edit-ltr-progressive.svg

Android Runtime (ART) is an application runtime environment used by the Android operating system. Replacing Dalvik, the process virtual machine originally used by Android, ART performs the translation of the application's bytecode into native instructions that are later executed by the device's runtime environment. [2]

Contents

Overview

A comparison of Dalvik and ART architectures ART view.png
A comparison of Dalvik and ART architectures

Android 2.2 "Froyo" brought trace-based just-in-time (JIT) compilation into Dalvik, optimizing the execution of applications by continually profiling applications each time they run and dynamically compiling frequently executed short segments of their bytecode into native machine code. While Dalvik interprets the rest of an application's bytecode, native execution of those short bytecode segments, called "traces", provides significant performance improvements. [3] [4]

Unlike Dalvik, ART introduces the use of ahead-of-time (AOT) compilation by compiling entire applications into native machine code upon their installation. By eliminating Dalvik's interpretation and trace-based JIT compilation, ART improves the overall execution efficiency and reduces power consumption, which results in improved battery autonomy on mobile devices. At the same time, ART brings faster execution of applications, improved memory allocation and garbage collection (GC) mechanisms, new applications debugging features, and more accurate high-level profiling of applications. [2] [5] [6]

To maintain backward compatibility, ART uses the same input bytecode as Dalvik, supplied through standard .dex files as part of APK files, while the .odex files are replaced with Executable and Linkable Format (ELF) executables. Once an application is compiled by using ART's on-device dex2oat utility, it is run solely from the compiled ELF executable; as a result, ART eliminates various application execution overheads associated with Dalvik's interpretation and trace-based JIT compilation. A disadvantage of ART is that additional time is required for compilation when an application is installed, and applications take up slightly more secondary storage (usually flash memory) to store the compiled code. [2] [5] [6]

History

Android 4.4 "KitKat" introduced a technology preview of ART as an alternative runtime environment to Dalvik, which remained the default virtual machine. [7] [8] In the subsequent major Android release, Android 5.0 "Lollipop", Dalvik was entirely replaced by ART.

Android 7.0 "Nougat" switched its Java Runtime Environment from the discontinued Apache Harmony to OpenJDK, introducing a JIT compiler with code profiling to ART, which lets it constantly improve the performance of Android apps as they run. [9] The JIT compiler complements ART's AOT compiler, helping to improve runtime performance and save storage space by identifying "hot code" (code which is frequently used, runs on the UI thread or affects startup time), which the AOT compiler compiles to machine code while the device is idle and charging. Less-frequently used code relies on JIT compilation. [10] [11]

Android 9 "Pie" reduced the amount of storage used by APKs by using compressed bytecode files, and profiler data can be uploaded to Google Play servers to be bundled with apps when downloaded by users with a similar device, which shortens download time from Google Play by up to 40%. Google Play cloud profiles allow apps to be optimized on install, which helps avoid the initial performance issues present on Android 7.0 to 8.1. [12]

In July 2021, [13] the concept of baseline profiles was introduced. Baseline profiles are ART profiles that define methods and classes which should undergo AOT compilation from an app's first launch. They provide similar functionality to Android 9's Google Play cloud profiles on Android 7.0 to 8.1, and automatically merge with cloud profiles on Android 9 and later. [14]

ART was updated with a new garbage collector (GC) utilizing the Linux userfaultfd system call in Android 13. [15] [16] [17] It reduces memory pressure, compiled code size, jank and prevents the risk of killing apps because of low memory during GC. [17] Other changes also improve app startup, reduce jank and improve performance. [17] Because of the Mainline project, Android 12 ART will also be updated. [15]

See also

Related Research Articles

<span class="mw-page-title-main">Java (programming language)</span> Object-oriented programming language

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities that are typically not available in traditional compiled languages. As of 2019, Java was one of the most popular programming languages in use according to GitHub, particularly for client–server web applications, with a reported 9 million developers.

<span class="mw-page-title-main">Java virtual machine</span> Java Virtual machine

A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation. Having a specification ensures interoperability of Java programs across different implementations so that program authors using the Java Development Kit (JDK) need not worry about idiosyncrasies of the underlying hardware platform.

Common Intermediate Language (CIL), formerly called Microsoft Intermediate Language (MSIL) or Intermediate Language (IL), is the intermediate language binary instruction set defined within the Common Language Infrastructure (CLI) specification. CIL instructions are executed by a CLI-compatible runtime environment such as the Common Language Runtime. Languages which target the CLI compile to CIL. CIL is object-oriented, stack-based bytecode. Runtimes typically just-in-time compile CIL instructions into native code.

Bytecode is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references that encode the result of compiler parsing and performing semantic analysis of things like type, scope, and nesting depths of program objects.

In computing, just-in-time (JIT) compilation is compilation during execution of a program rather than before execution. This may consist of source code translation but is more commonly bytecode translation to machine code, which is then executed directly. A system implementing a JIT compiler typically continuously analyses the code being executed and identifies parts of the code where the speedup gained from compilation or recompilation would outweigh the overhead of compiling that code.

Jazelle DBX is an extension that allows some ARM processors to execute Java bytecode in hardware as a third execution state alongside the existing ARM and Thumb modes. Jazelle functionality was specified in the ARMv5TEJ architecture and the first processor with Jazelle technology was the ARM926EJ-S. Jazelle is denoted by a "J" appended to the CPU name, except for post-v5 cores where it is required for architecture conformance.

In computer programming, a programming language implementation is a system for executing computer programs. There are two general approaches to programming language implementation:

In computer science, ahead-of-time compilation is the act of compiling an (often) higher-level programming language into an (often) lower-level language before execution of a program, usually at build-time, to reduce the amount of work needed to be performed at run time.

Eclipse OpenJ9 is a high performance, scalable, Java virtual machine (JVM) implementation that is fully compliant with the Java Virtual Machine Specification.

Dalvik is a discontinued process virtual machine (VM) in the Android operating system that executes applications written for Android. Dalvik was an integral part of the Android software stack in the Android versions 4.4 "KitKat" and earlier, which were commonly used on mobile devices such as mobile phones and tablet computers, and more in some devices such as smart TVs and wearables. Dalvik is open-source software, originally written by Dan Bornstein, who named it after the fishing village of Dalvík in Eyjafjörður, Iceland.

<span class="mw-page-title-main">V8 (JavaScript engine)</span> Open-source JavaScript and WebAssembly engine developed by Google

V8 is a free and open-source JavaScript and WebAssembly engine developed by the Chromium Project for Chromium and Google Chrome web browsers. The project's creator is Lars Bak. The first version of the V8 engine was released at the same time as the first version of Chrome: 2 September 2008. It has also been used on the server side, for example in Couchbase, Deno and Node.js.

Dalvik Turbo is a proprietary alternative to Google's implementation of the Dalvik virtual machine that runs on the Android operating system and other platforms developed by French/Swiss firm Myriad Group.

This article compares the application programming interfaces (APIs) and virtual machines (VMs) of the programming language Java and operating system Android.

Dart is a programming language designed by Lars Bak and Kasper Lund and developed by Google. The programming language can be used to develop web and mobile apps as well as server and desktop applications.

<span class="mw-page-title-main">Mono (software)</span> Computer software project

Mono is a free and open-source .NET Framework-compatible software framework. Originally by Ximian, it was later acquired by Novell, and is now being led by Xamarin, a subsidiary of Microsoft and the .NET Foundation. Mono can be run on many software systems.

Tracing just-in-time compilation is a technique used by virtual machines to optimize the execution of a program at runtime. This is done by recording a linear sequence of frequently executed operations, compiling them to native machine code and executing them. This is opposed to traditional just-in-time (JIT) compilers that work on a per-method basis.

Excelsior JET is a now-defunct proprietary Java SE technology implementation built around an ahead-of-time (AOT) Java to native code compiler. The compiler transforms the portable Java bytecode into optimized executables for the desired hardware and operating system (OS). Also included are a Java runtime featuring a just-in-time (JIT) compiler for handling classes that were not precompiled for whatever reason, the complete Java SE API implementation licensed from Oracle, and a toolkit to aid deployment of the optimized applications. Excelsior JET is developed by Excelsior LLC, headquartered in Novosibirsk, Russia.

<span class="mw-page-title-main">GraalVM</span> Java virtual machine

GraalVM is a Java VM and JDK based on HotSpot/OpenJDK, implemented in Java. It supports additional programming languages and execution modes, like ahead-of-time compilation of Java applications for fast startup and low memory footprint. The first production-ready version, GraalVM 19.0, was released in May 2019. The most recent version is GraalVM 23.0.0 , made available in June 2023.

<span class="mw-page-title-main">Android KitKat</span> Eleventh version of the Android operating system

Android KitKat is the codename for the eleventh Android mobile operating system, representing release version 4.4. Unveiled on September 3, 2013, KitKat focused primarily on optimizing the operating system for improved performance on entry-level devices with limited resources. The first phone with Android KitKat was the Nexus 5.

<span class="mw-page-title-main">Android Lollipop</span> Fifth major version of the Android operating system

Android Lollipop is the fifth major version of the Android mobile operating system developed by Google and the 12th version of Android, spanning versions between 5.0 and 5.1.1. Unveiled on June 25, 2014 at the Google I/O 2014 conference, it became available through official over-the-air (OTA) updates on November 12, 2014, for select devices that run distributions of Android serviced by Google. Its source code was made available on November 3, 2014. The first phone with Android Lollipop was the Nexus 6.

References

  1. "NOTICE - platform/art - Git at Google". Archived from the original on March 4, 2023. Retrieved June 25, 2021.
  2. 1 2 3 Andrei Frumusanu (July 1, 2014). "A Closer Look at Android RunTime (ART) in Android L". AnandTech. Archived from the original on July 5, 2014. Retrieved July 5, 2014.
  3. Ben Cheng; Bill Buzbee (May 2010). "A JIT Compiler for Android's Dalvik VM" (PDF). android-app-developer.co.uk. Google. pp. 5–14. Archived from the original (PDF) on November 6, 2015. Retrieved March 18, 2015.
  4. Phil Nickinson (May 26, 2010). "Google Android developer explains more about Dalvik and the JIT in Froyo". androidcentral.com. Archived from the original on April 8, 2017. Retrieved July 8, 2014.
  5. 1 2 "Android Developers: ART and Dalvik". source.android.com. March 9, 2015. Archived from the original on March 15, 2015. Retrieved March 18, 2015.
  6. 1 2 "Android Developers: Configuring ART – How ART works". source.android.com. March 9, 2015. Retrieved March 18, 2015.
  7. Sean Buckley (November 6, 2013). "'ART' experiment in Android KitKat improves battery life and speeds up apps". Engadget. Archived from the original on January 27, 2017. Retrieved July 5, 2014.
  8. Daniel P. (November 7, 2013). "Experimental Google ART runtime in Android KitKat can bring twice faster app executions". phonearena.com. Archived from the original on July 7, 2014. Retrieved July 5, 2014.
  9. "Android 7.0 for Developers". Android Developers. Retrieved March 22, 2021.
  10. Amadeo, Ron (August 22, 2016). "Android 7.0 Nougat review—Do more on your gigantic smartphone". Ars Technica . Retrieved April 5, 2023.
  11. "Implementing ART Just-In-Time (JIT) Compiler". source.android.com. January 22, 2017. Archived from the original on August 8, 2023. Retrieved January 22, 2017.
  12. Amadeo, Ron (September 13, 2018). "Android 9 Pie, thoroughly reviewed". Ars Technica. Archived from the original on November 30, 2018. Retrieved August 16, 2022.
  13. "ProfileInstaller | Jetpack". Android Developers. Archived from the original on August 8, 2023. Retrieved July 5, 2023.
  14. Semenova, Kateryna; Ravikumar, Rahul; Craik, Chris (January 28, 2022). "Improving App Performance with Baseline Profiles". Android Developers Blog. Archived from the original on August 8, 2023. Retrieved July 5, 2023.
  15. 1 2 Gidra, Lokesh, What's new in app performance, archived from the original on August 16, 2022, retrieved August 16, 2022
  16. Gidra, Lokesh; Boehm, Hans-J.; Fernandes, Joel (October 12, 2020). "Utilizing the Linux Userfaultfd System Call in a Compaction Phase of a Garbage Collection Process". Defensive Publications Series. Archived from the original on August 16, 2022. Retrieved August 16, 2022.
  17. 1 2 3 "Android 13 is in AOSP!". Android Developers Blog. Archived from the original on August 15, 2022. Retrieved August 16, 2022.