art (aot) vs dalvik (jit)

33
ART vs Dalvik Introducing the New Android x86 Runtime

Upload: bhavik-limani

Post on 02-Dec-2014

440 views

Category:

Technology


5 download

DESCRIPTION

ART (AOT) vs DALVIK (JIT) Introducing the New Android x86 Runtime What is virtual machine ? Life-Time of APK What is Dalvik Virtual Machine ? Dalvik History Execution of Dalvik Architecture of Dalvik Storage Mechanism Characteristics Of Dalvik Performance of Dalvik Licensing and Patents of Dalvik JEB De-compiler for Dalvik Android Runtime (ART) Dalvik vs ART Enable ART on Android KitKat 4.4 Survey-1 of Google Device’s Nexus 5 Survey-2 of Google Device’s Nexus 5 in Google I/O Release… JIT(Dalvik) vs AOT(ART) *Performance *Battery Life *Installation Time *Storage Footprint Thank's

TRANSCRIPT

Page 1: ART (AOT)  vs  DALVIK (JIT)

ART vs Dalvik

Introducing the New Android x86 Runtime

Page 2: ART (AOT)  vs  DALVIK (JIT)

What is virtual machine ?

• A virtual machine is like a software implementation of a physical computer which works like real physical computer.

• It means a virtual machine can compile and run any program just like a physical computer does for us.

• But there is a dark-side of virtual machine as it is less efficient than real physical computer and provide unstable performance when multiple virtual machine exist on the same machine.

Page 3: ART (AOT)  vs  DALVIK (JIT)
Page 4: ART (AOT)  vs  DALVIK (JIT)

Life-Time of APK

Page 5: ART (AOT)  vs  DALVIK (JIT)

What is Dalvik Virtual Machine ?

• Dalvik is the Process virtual machine (VM) in Google's Android operating system.

• Which specifically executes applications written for Android.

• This makes Dalvik an integral part of the Android software Stack, which is typically used on mobile devices such as mobile phones and tablet computers, as well as more recently on devices such as smart TVs and wearables.

Page 6: ART (AOT)  vs  DALVIK (JIT)

Dalvik History

• Original Author :- Dan BornStein• Operating System :- Linux Kernel• Platform :- Android• Type :- Virtual Machine• License :- Apache License 2.0• Site: https://source.android.com/devices/tech/dalvik/index.html

• Filename Extension :- .dex

Page 7: ART (AOT)  vs  DALVIK (JIT)

Execution of Dalvik

Page 8: ART (AOT)  vs  DALVIK (JIT)
Page 9: ART (AOT)  vs  DALVIK (JIT)
Page 10: ART (AOT)  vs  DALVIK (JIT)
Page 11: ART (AOT)  vs  DALVIK (JIT)
Page 12: ART (AOT)  vs  DALVIK (JIT)

Dalvik Execution

• Programs are commonly written in Java and compiled to bytecode for the Java virtual machine, which is then translated to Dalvik bytecode and stored in .dex (Dalvik EXecutable) and .odex (Optimized Dalvik EXecutable) files.

• The compact Dalvik Executable format is designed for systems that are constrained in terms of memory and processor speed.

Page 13: ART (AOT)  vs  DALVIK (JIT)

Architecture of Dalvik

Page 14: ART (AOT)  vs  DALVIK (JIT)

Storage Mechanism Dalvik programs are written in Java

using the Android application programming interface (API), compiled to Java bytecode, and converted to Dalvik instructions as necessary.

A tool called dx is used to convert Java .class files into the .dex format. Multiple classes are included in a single .dex file. Duplicate strings and other constants used in multiple class files are included only once in the .dex output to conserve space.

As of Android 2.2, Dalvik has a just-in-time compiler.

Page 15: ART (AOT)  vs  DALVIK (JIT)

Characteristics Of Dalvik The VM was slimmed down to use less

space. The constant pool has been modified to

use only 32-bit indices to simplify the interpreter. 

Standard Java bytecode executes 8-bit stack instructions. Local variables must be copied to or from the operand stack by separate instructions.

Dalvik instead uses its own 16-bit instruction set that works directly on local variables. The local variable is commonly picked by a 4-bit 'virtual register' field. This lowers Dalvik's instruction count and raises its interpreter speed.

According to Google, the design of Dalvik permits a device to run multiple instances of the VM efficiently.

Page 16: ART (AOT)  vs  DALVIK (JIT)

Performance of Dalvik

• Generally, stack-based machines must use instructions to load data on the stack and manipulate that data and thus, require more instructions than register machines to implement the same high level code, but the instructions in a register machine must encode the source and destination registers and, therefore, tend to be larger.

Page 17: ART (AOT)  vs  DALVIK (JIT)

Licensing and Patents of Dalvik

• Dalvik is published under the terms of the Apache License2.0.

• Google says that Dalvik is a clean-room implementation rather than a development on top of a standard Java runtime, which would mean it does not inherit copyright-based license restrictions from either the standard-edition or open-source-edition Java runtimes and some reviewers dispute this.

Page 18: ART (AOT)  vs  DALVIK (JIT)

JEB De-compiler for Dalvik

• JEB is a disassembler and decompiler software for Android applications.

• It decompiles Dalvik bytecode to Java source code.

• The assembly and Java outputs are interactive and can be refactored.

• Users can also write their own scripts and plugins to extend JEB functionality.

Page 19: ART (AOT)  vs  DALVIK (JIT)

JEB continue….

• JEB is the first Dalvik de-compiler to provide interactive output, as reverse-engineers may examine cross-references, insert comments, or rename items, such as classes and methods.

• Whenever possible, the correspondence between the bytecode and the decompiled Java code is accessible to the user.

• Although JEB is branded as a de-compiler, it also provides a full APK view (manifest, resources, certificates, etc.)

Page 20: ART (AOT)  vs  DALVIK (JIT)

Android Runtime (ART)

• Android Runtime (ART) is an application runtime environment used by the Android mobile operating system.

• ART replaces Dalvik, which is the process virtual machine originally used by Android, and performs transformation of the application's bytecode into native instructions that are later executed by the device's runtime environment.

• Unlike Dalvik, which since Android 2.2 "Froyo" uses just-in-time (JIT) compilation to compile the bytecode every time an application is launched.

Page 21: ART (AOT)  vs  DALVIK (JIT)

Android Runtime (ART) Continue…

• ART introduces use of ahead-of-time (AOT) compilation by performing it upon the installation of an application. By reducing the overall amount of compilation that needs to be performed across the operation of an application, a mobile device's processor usage is reduced and battery runtime is improved.

• At the same time, ART brings improvements in performance, garbage collection, applications debugging and profiling.

Page 22: ART (AOT)  vs  DALVIK (JIT)

Android Runtime (ART) Continue…

• 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; this approach eliminates various overheads involved with JIT compilation, but it requires additional time for compilation when an application is installed, and applications take up slightly larger amounts of space to store the compiled code.

Page 23: ART (AOT)  vs  DALVIK (JIT)

Dalvik vs ARTDalvik ART

Uses Just-In-Time (JIT) approach, which results in lower storage space consumption but longer app load times

Uses Ahead-Of-Time (AOT) approach, which compiles apps when they’re installed, resulting in faster load times and lower processor usage

Cache builds up over time, so boot times are faster

Cache is built at first boot, hence rebooting device takes significantly longer

Works better for lower internal storage devices as space occupied is lesser

Consumes much more internal storage space since it stores compiled apps in addition to the APKs

Is stable and time tested – VM of choice for app developers

Is highly experimental and new – not a lot of support from app developers yet

Page 24: ART (AOT)  vs  DALVIK (JIT)

Enable ART on Android KitKat 4.4

Page 25: ART (AOT)  vs  DALVIK (JIT)

Survey-1 of Google Device’s Nexus 5

Page 26: ART (AOT)  vs  DALVIK (JIT)

Survey-2 of Google Device’s Nexus 5 in Google I/O Release…

Page 27: ART (AOT)  vs  DALVIK (JIT)

JIT(Dalvik) vs AOT(ART)

• The most significant change from Dalvik to ART is that Dalvik is based on Just-in-Time (JIT) compilation, while ART is based on Ahead-of-Time (AOT) compilation.

Page 28: ART (AOT)  vs  DALVIK (JIT)

JIT(Dalvik) vs AOT(ART)

• Performance– The most important benefit of ART runtime over

Dalvik runtime is that the app runs faster on ART. 

– Because DEX bytecode has been translated into machine code during installation, no extra time is needed to compile it during the runtime.

– The app starts faster as well when launched with ART for the same reason.

– Because Dalvik requires extra memory for JIT code cache, an app occupies a smaller memory footprint when it runs on ART.

Page 29: ART (AOT)  vs  DALVIK (JIT)

JIT(Dalvik) vs AOT(ART)

• Battery Life–With Dalvik runtime, the JIT compilation

is CPU bound.– Because of AOT compilation, ART frees

the CPU from translating DEX bytecode to machine code during the app’s execution

– Thus reducing energy consumption. Using ART leads to a longer battery life, which is the time interval when a battery recharging is needed.

Page 30: ART (AOT)  vs  DALVIK (JIT)

JIT(Dalvik) vs AOT(ART)

• Installation Time– Because the AOT compiler translates

DEX bytecode into machine code during the app installation, an app takes longer to install on a device with ART runtime.

– Considering the benefits of faster execution and shorter launch time we discussed in the previous section, this extra time which happens only once during the app’s installation is well worth it.

Page 31: ART (AOT)  vs  DALVIK (JIT)

JIT(Dalvik) vs AOT(ART)

• Storage Footprint–With ART runtime, the AOT compiler

translates the app’s DEX bytecode into machine code and stores it in the device’s storage.

– The pre-compiled binary occupies more space than the DEX bytecode.

– Thus results in a larger storage footprint comparing with Dalvik runtime.

Page 32: ART (AOT)  vs  DALVIK (JIT)

Reference’s• http://en.wikipedia.org/wiki/JEB_Decompiler

• http://en.wikipedia.org/wiki/Dalvik(software)

• https://developer.android.com/guide/practices/verifying-apps-art.html

• https://source.android.com/devices/tech/dalvik/art.html#features

• http://android.stackexchange.com/questions/56773/dalvik-vm-vs-art-android-runtime-impact-for-end-users

• http://www.theverge.com/2014/10/15/6983275/android-5-0-lollipop-gets-its-statue

• https://software.intel.com/en-us/blogs/2014/06/18/art-vs-dalvik-introducing-the-new-android-x86-runtime

Page 33: ART (AOT)  vs  DALVIK (JIT)

Thank You