SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
ART JIT in Android N
Xueliang ZHONG
Linaro ART Team
linaro-art@linaro.org
1
ENGINEERS
AND DEVICES
WORKING
TOGETHER
Outline
● Android Runtime (ART) and the new challenges
● ART Implementation in Android N
● Tooling
● Performance Data & Findings
● Q & A
2
ENGINEERS AND DEVICES
WORKING TOGETHER
ART
● Android Runtime (ART)
● Performance Requirements for ART:
○ Run APPs smoothly.
○ Fast APP startup.
○ Fast APP installation.
○ With minimal overhead.
■ CPU, memory, storage, power, ...
Android APP
Android Framework
Native Lib
HAL
Linux Kernel
ART
3
ENGINEERS AND DEVICES
WORKING TOGETHER
Android KitKat Just-In-Time (JIT) Solution
JITINSTALL
Native
Code
● Dynamic compilation
APK
DEX
Code
START
APP
4
ENGINEERS AND DEVICES
WORKING TOGETHER
Android KitKat Just-In-Time (JIT) Solution
JITINSTALL
Native
Code
APK
DEX
Code
START
APP
Fast
Installation
Less Storage
Required
JIT compilation overhead
Runtime battery overhead
5
ENGINEERS AND DEVICES
WORKING TOGETHER
Android Marshmallow Ahead-Of-Time (AOT) Solution
● Static compilation
APK
INSTALL
(AOT)
Native
Code
START
APP
6
ENGINEERS AND DEVICES
WORKING TOGETHER
Android Marshmallow Ahead-Of-Time (AOT) Solution
APK
INSTALL
(AOT)
Native
Code
START
APP
Fast startup performanceMore Storage
Required
Slow
Installation
Fast runtime performance
Less runtime battery consumption
7
ENGINEERS AND DEVICES
WORKING TOGETHER
More Challenges for AOT Nowadays
APK
INSTALL
(AOT)
Native
Code
START
APP
● System
Update Time
● Storage
Consumption
● Dynamic APK
8
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Implementation in Android N
JITAPK INSTALL
DEX
Code
START
APP
Native
Code
AOT
Native
Code
START
APP
PROFILE
Compilation
Daemon
Service
9
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Implementation in Android N
JITAPK INSTALL
DEX
Code
START
APP
Native
Code
● JIT Phase
○ Fast installation
○ Fast system update time (OTA)
AOT
Native
Code
START
APP
Compilation
Daemon
Service
10
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Implementation in Android N
AOT
Native
Code
START
APP
Compilation
Daemon
Service
● Profile Guided AOT:
○ Fast startup and runtime performance
○ Lower overheads: CPU, storage, power ...
JITAPK INSTALL
DEX
Code
START
APP
Native
Code
11
ENGINEERS AND DEVICES
WORKING TOGETHER
ART JIT - Implementation Overview
JITAPK INSTALL
DEX
Code
START
APP
Native
Code
● JIT Runtime
● JIT Compiler
● Generates Profile File
12
ENGINEERS AND DEVICES
WORKING TOGETHER
ART JIT - Implementation Overview
JITAPK INSTALL
DEX
Code
START
APP
Native
Code
● JIT Runtime
● JIT Compiler
● Generates Profile File
● Interpreter
○ Computed-goto based
○ Opcode handling in ARM assembly
● Profiling & Triggering JIT Compilation
○ Based on execution count and heuristics
○ ‘hotness_count’
● JIT Code Cache
○ Manages JITed Code
○ Allocating ‘ProfilingInfo’ for hot methods
13
ENGINEERS AND DEVICES
WORKING TOGETHER
ART JIT - Implementation Overview
JITAPK INSTALL
DEX
Code
START
APP
Native
Code
● JIT Runtime
● JIT Compiler
● Generates Profile File
● Method granularity compilation
● Background compilation.
○ Avoid blocking APP thread (e.g. UI thread)
● Based on ART optimizing compiler.
○ Same compiler used for AOT compilation.
● JIT compilation enhancements in
optimizing compiler
14
ENGINEERS AND DEVICES
WORKING TOGETHER
ART JIT - Implementation Overview
JITAPK INSTALL
DEX
Code
START
APP
Native
Code
● JIT Runtime
● JIT Compiler
● Generates Profile File● ProfileSaver thread
○ Reads ‘ProfilingInfo’ about hot methods
○ Writes such info to disk
● Minimize overhead
○ Wakeup frequency
○ Minimize things to write
15
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode
● Idea of Hybrid Mode (JIT + AOT)
…..
…..
16
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode
● Idea of Hybrid Mode (JIT + AOT)
○ Some users only use part of the APP. Only these
frequently used features (and code behind
them) are worth compiling into native code.
…..
…..
17
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode
● Idea of Hybrid Mode (JIT + AOT)
○ Some users only use part of the APP. Only
frequently used features (and code behind
them) are worth compiling into native code.
○ Use JIT phase to find out the frequently used
code.
…..
…..
18
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode
● Idea of Hybrid Mode (JIT + AOT)
○ Some users only use part of the APP. Only
frequently used features (and code behind
them) are worth compiling into native code.
○ Use JIT phase to find out the frequently used
code.
○ Use AOT compilation & optimization to speed up
frequent use cases.
…..
…..
19
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode
● Idea of Hybrid Mode (JIT + AOT)
○ Some users only use part of the APP. Only
frequently used features (and code behind
them) are worth compiling into native code.
○ Use JIT phase to find out the frequently used
code.
○ Use AOT compilation & optimization to speed up
frequent use cases.
○ Avoid paying overheads (compilation, storage,
etc) to those less used codes.
…..
…..
20
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode - Overview
● Implementation
○ Generate Offline Profile During JIT
○ Offline Profile File Format
○ Enhanced AOT Compiler (dex2oat)
○ Compilation Daemon Service
…..
…..
21
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode
base.apk
methods: 1,2,5
classes: 0,6,13
base.apk:classes2.dex
methods: 5,12,28
classes: 17,19,33
JITAPK INSTALL
DEX
Code
START
APP
Native
Code
PROFILE
Offline Profile File
● Each APP has its own profile.
● Stored in APP local storage.
● Simple format.
● Analysis through profman tool.
22
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode
● Compilation Daemon
○ Triggers AOT when the device is charging and idle.
○ ‘BackgroundDexOptService’
○ frameworks/base/services/core/java/com/android/server/pm/
…..
…..
AOT
Native
Code
Compilation
Daemon
Service
23
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode
JITAPK INSTALL
DEX
Code
START
APP
Native
Code
PROFILE
Profile Guided AOT
● dex2oat enhanced to accept profile
● selective compilation based on profile
AOT
Native
Code
START
APP
Compilation
Daemon
Service
dex2oat32 I compiler_driver.cc Skipped method:void MyClass.<init>()
dex2oat32 I compiler_driver.cc Compiled method:int MyClass.foo(int)
dex2oat32 I compiler_driver.cc Compiled method:void MyClass.main()
dex2oat32 I compiler_driver.cc Skipped method:boolean MyClass.verify()
dex2oat32 I compiler_driver.cc Skipped method:void Class2.<init>()
24
ENGINEERS AND DEVICES
WORKING TOGETHER
ART Hybrid Mode
● Run in Hybrid Mode
○ All previous ‘hot’ methods are AOT compiled
○ JIT compiler is still loaded in memory
■ For unexplored features/codes.
■ May generate new profiles.
…..
…..
25
ENGINEERS AND DEVICES
WORKING TOGETHER
Tools
● TraceView (Android Studio / Android SDK)
26
ENGINEERS AND DEVICES
WORKING TOGETHER
Tools
● Systrace (Android Studio / Android SDK)
○ Enable 'dalvik' trace
○ Analyze JIT behaviors: JIT code cache, ProfilerSaver, GC, etc.
○ Helps to measure:
i. Invoke Time (1, 5, 6)
ii. JIT compilation time for each method (2, 3)
iii. JITed code execution (4)
27
ENGINEERS AND DEVICES
WORKING TOGETHER
Tools
● JIT Compiler Analysis
○ CFG dump
■ CFG file analysis:
○ Profiling JITed code
■ Support generating /tmp/perf-PID-maps for method level profiling with perf.
■ Profile AOT compiled code is prefered, for instruction level profiling.
○ Other useful JIT statistics & logs:
■ -verbose:compiler, -verbose:jit
■ -XX:DumpJITInfoOnShutdown
dalvikvm -Xusejit:true -Xcompiler-option --dump-cfg=jit.cfg -cp Main.dex Main
28
ENGINEERS AND DEVICES
WORKING TOGETHER
Tools
● Profile Guided AOT Analysis - profman
profman --profile-file=<filename> --dump-only
This command can dump the contents in the given prof file.
profman --generate-test-profile=<filename>
This command can generate a random profile file for testing.
runtime/jit/offline_profiling_info.cc
// Debug flag to ignore checksums when testing.
// Used to facilitate testing across a large number of apps.
static constexpr bool kDebugIgnoreChecksum = true;
compiler/driver/compiler_driver.cc
// Print additional info during profile guided compilation.
static constexpr bool kDebugProfileGuidedCompilation = true;
29
ENGINEERS AND DEVICES
WORKING TOGETHER
Performance & Findings
● A Popular News Reader APP
30
ENGINEERS AND DEVICES
WORKING TOGETHER
Performance & Findings
● A Popular News Reader APP
31
ENGINEERS AND DEVICES
WORKING TOGETHER
Performance & Findings
● Micro Benchmark Performance, AOT vs. JIT
32
ENGINEERS AND DEVICES
WORKING TOGETHER
More Talks & Resources
● Linaro-ART Team:
○ VIXL: A Programmatic Assembler and Disassembler for AArch32
○ Android Runtime Performance Analysis
● The Evolution of ART - Google I/O 2016
○ https://www.youtube.com/watch?v=fwMM6g7wpQ8
● Implementing ART Just-In-Time (JIT) Compiler
○ http://source.android.com/devices/tech/dalvik/jit-compiler.html
33
Thank You
#LAS16
For further information: www.linaro.org
LAS16 keynotes and videos on: connect.linaro.org
34
ENGINEERS AND DEVICES
WORKING TOGETHER
Backup
35
ENGINEERS AND DEVICES
WORKING TOGETHER
Performance & Findings - Example
● Micro Benchmarking – Running Unexpected Modes
void runAlgorithm(int iterations) {
for(i=0; i<iterations; i++) {
// long operations …
}
}
void main() {
int iterations = 20000;
int before = time();
runAlgorithm(iterations);
int after = time();
// …
}
36
ENGINEERS AND DEVICES
WORKING TOGETHER
Performance & Findings - Example
● JIT’s Advantage over AOT – Inlining
public class MyClass {
public /*private*/ /*final*/ /*static*/ int arithmeticSeries(int i)
{
if(i == 0)
return 0;
else
return i + arithmeticSeries(i - 1); // invoke-virtual
}
}
37
ENGINEERS AND DEVICES
WORKING TOGETHER
ART JIT - Workflow
38

Weitere ähnliche Inhalte

Was ist angesagt?

Las16 309 - lua jit arm64 port - status
Las16 309 - lua jit arm64 port - statusLas16 309 - lua jit arm64 port - status
Las16 309 - lua jit arm64 port - status
Linaro
 
LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)
Linaro
 

Was ist angesagt? (20)

LAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg developmentLAS16-TR06: Remoteproc & rpmsg development
LAS16-TR06: Remoteproc & rpmsg development
 
LAS16-TR03: Upstreaming 201
LAS16-TR03: Upstreaming 201LAS16-TR03: Upstreaming 201
LAS16-TR03: Upstreaming 201
 
Las16 309 - lua jit arm64 port - status
Las16 309 - lua jit arm64 port - statusLas16 309 - lua jit arm64 port - status
Las16 309 - lua jit arm64 port - status
 
Las16 200 - firmware summit - ras what is it- why do we need it
Las16 200 - firmware summit - ras what is it- why do we need itLas16 200 - firmware summit - ras what is it- why do we need it
Las16 200 - firmware summit - ras what is it- why do we need it
 
BUD17-310: Introducing LLDB for linux on Arm and AArch64
BUD17-310: Introducing LLDB for linux on Arm and AArch64 BUD17-310: Introducing LLDB for linux on Arm and AArch64
BUD17-310: Introducing LLDB for linux on Arm and AArch64
 
LAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to EmbeddedLAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
 
LAS16-310: Introducing the first 96Boards TV Platform: Poplar by Hisilicon
LAS16-310: Introducing the first 96Boards TV Platform: Poplar by HisiliconLAS16-310: Introducing the first 96Boards TV Platform: Poplar by Hisilicon
LAS16-310: Introducing the first 96Boards TV Platform: Poplar by Hisilicon
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
 
LAS16-207: Bus scaling QoS
LAS16-207: Bus scaling QoSLAS16-207: Bus scaling QoS
LAS16-207: Bus scaling QoS
 
LAS16-405:OpenDataPlane: Software Defined Dataplane leader
LAS16-405:OpenDataPlane: Software Defined Dataplane leaderLAS16-405:OpenDataPlane: Software Defined Dataplane leader
LAS16-405:OpenDataPlane: Software Defined Dataplane leader
 
LAS16-305: Smart City Big Data Visualization on 96Boards
LAS16-305: Smart City Big Data Visualization on 96BoardsLAS16-305: Smart City Big Data Visualization on 96Boards
LAS16-305: Smart City Big Data Visualization on 96Boards
 
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation GuideBKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
 
LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)LAS16-400: Mini Conference 3 AOSP (Session 1)
LAS16-400: Mini Conference 3 AOSP (Session 1)
 
LAS16-100K1: Welcome Keynote
LAS16-100K1: Welcome KeynoteLAS16-100K1: Welcome Keynote
LAS16-100K1: Welcome Keynote
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!
 
LAS16-108: JerryScript and other scripting languages for IoT
LAS16-108: JerryScript and other scripting languages for IoTLAS16-108: JerryScript and other scripting languages for IoT
LAS16-108: JerryScript and other scripting languages for IoT
 
BKK16-213 Where's the Hardware?
BKK16-213 Where's the Hardware?BKK16-213 Where's the Hardware?
BKK16-213 Where's the Hardware?
 
BKK16-400A LuvOS and ACPI Compliance Testing
BKK16-400A LuvOS and ACPI Compliance TestingBKK16-400A LuvOS and ACPI Compliance Testing
BKK16-400A LuvOS and ACPI Compliance Testing
 
LAS16-406: Android Widevine on OP-TEE
LAS16-406: Android Widevine on OP-TEELAS16-406: Android Widevine on OP-TEE
LAS16-406: Android Widevine on OP-TEE
 
LAS16-507: LXC support in LAVA
LAS16-507: LXC support in LAVALAS16-507: LXC support in LAVA
LAS16-507: LXC support in LAVA
 

Andere mochten auch

HKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewHKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overview
Linaro
 
Android Code Optimization Techniques
Android Code Optimization TechniquesAndroid Code Optimization Techniques
Android Code Optimization Techniques
Ishrat khan
 
Compiler optimization
Compiler optimizationCompiler optimization
Compiler optimization
liu_ming50
 
Android Code Optimization Techniques 2
Android Code Optimization Techniques 2Android Code Optimization Techniques 2
Android Code Optimization Techniques 2
Ishrat khan
 
Tuning Android Applications (Part One)
Tuning Android Applications (Part One)Tuning Android Applications (Part One)
Tuning Android Applications (Part One)
CommonsWare
 

Andere mochten auch (20)

Google ART (Android RunTime)
Google ART (Android RunTime)Google ART (Android RunTime)
Google ART (Android RunTime)
 
HKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewHKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overview
 
Introduction to ART (Android Runtime)
Introduction to ART (Android Runtime)Introduction to ART (Android Runtime)
Introduction to ART (Android Runtime)
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
iOS Application Testing
iOS Application TestingiOS Application Testing
iOS Application Testing
 
Performance optimization for Android
Performance optimization for AndroidPerformance optimization for Android
Performance optimization for Android
 
BKK16-306 ART ii
BKK16-306 ART iiBKK16-306 ART ii
BKK16-306 ART ii
 
GDG Devfest 2016 session on Android N
GDG Devfest 2016 session on Android NGDG Devfest 2016 session on Android N
GDG Devfest 2016 session on Android N
 
Android Code Optimization Techniques 3
Android Code Optimization Techniques 3Android Code Optimization Techniques 3
Android Code Optimization Techniques 3
 
Profile Guided Optimization
Profile Guided OptimizationProfile Guided Optimization
Profile Guided Optimization
 
C++ Optimization Tips
C++ Optimization TipsC++ Optimization Tips
C++ Optimization Tips
 
Android Code Optimization Techniques
Android Code Optimization TechniquesAndroid Code Optimization Techniques
Android Code Optimization Techniques
 
IoT
IoTIoT
IoT
 
Compiler optimization
Compiler optimizationCompiler optimization
Compiler optimization
 
Android Code Optimization Techniques 2
Android Code Optimization Techniques 2Android Code Optimization Techniques 2
Android Code Optimization Techniques 2
 
iOS Developer Overview - DevWeek 2014
iOS Developer Overview - DevWeek 2014iOS Developer Overview - DevWeek 2014
iOS Developer Overview - DevWeek 2014
 
Tuning Android Applications (Part One)
Tuning Android Applications (Part One)Tuning Android Applications (Part One)
Tuning Android Applications (Part One)
 
Objective-C for Java developers
Objective-C for Java developersObjective-C for Java developers
Objective-C for Java developers
 
Android performance tuning. Memory.
Android performance tuning. Memory.Android performance tuning. Memory.
Android performance tuning. Memory.
 
Deep Parameters Tuning for Android Mobile Apps
Deep Parameters Tuning for Android Mobile AppsDeep Parameters Tuning for Android Mobile Apps
Deep Parameters Tuning for Android Mobile Apps
 

Ähnlich wie LAS16-201: ART JIT in Android N

TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling ToolsTIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
Xiaozhe Wang
 
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
Paris Open Source Summit
 

Ähnlich wie LAS16-201: ART JIT in Android N (20)

Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
 
Strategies for developing and deploying your embedded applications and images
Strategies for developing and deploying your embedded applications and imagesStrategies for developing and deploying your embedded applications and images
Strategies for developing and deploying your embedded applications and images
 
Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013
 
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling ToolsTIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
 
LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205
 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by step
 
Investigation report on 64 bit support and some of new features in aosp master
Investigation report on 64 bit support and some of new features in aosp masterInvestigation report on 64 bit support and some of new features in aosp master
Investigation report on 64 bit support and some of new features in aosp master
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernel
 
Devoxx : being productive with JHipster
Devoxx : being productive with JHipsterDevoxx : being productive with JHipster
Devoxx : being productive with JHipster
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
 
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
 
Embedded platform choices
Embedded platform choicesEmbedded platform choices
Embedded platform choices
 
Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 

Mehr von Linaro

Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea GalloDeep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Linaro
 
HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018
Linaro
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Linaro
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
Linaro
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
Linaro
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
Linaro
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
Linaro
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
Linaro
 

Mehr von Linaro (20)

Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea GalloDeep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
 
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta VekariaArm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
 
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua MoraHuawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
 
Bud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qaBud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qa
 
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
 
HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018
 
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
 
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening Keynote
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8M
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

LAS16-201: ART JIT in Android N

  • 1. ART JIT in Android N Xueliang ZHONG Linaro ART Team linaro-art@linaro.org 1
  • 2. ENGINEERS AND DEVICES WORKING TOGETHER Outline ● Android Runtime (ART) and the new challenges ● ART Implementation in Android N ● Tooling ● Performance Data & Findings ● Q & A 2
  • 3. ENGINEERS AND DEVICES WORKING TOGETHER ART ● Android Runtime (ART) ● Performance Requirements for ART: ○ Run APPs smoothly. ○ Fast APP startup. ○ Fast APP installation. ○ With minimal overhead. ■ CPU, memory, storage, power, ... Android APP Android Framework Native Lib HAL Linux Kernel ART 3
  • 4. ENGINEERS AND DEVICES WORKING TOGETHER Android KitKat Just-In-Time (JIT) Solution JITINSTALL Native Code ● Dynamic compilation APK DEX Code START APP 4
  • 5. ENGINEERS AND DEVICES WORKING TOGETHER Android KitKat Just-In-Time (JIT) Solution JITINSTALL Native Code APK DEX Code START APP Fast Installation Less Storage Required JIT compilation overhead Runtime battery overhead 5
  • 6. ENGINEERS AND DEVICES WORKING TOGETHER Android Marshmallow Ahead-Of-Time (AOT) Solution ● Static compilation APK INSTALL (AOT) Native Code START APP 6
  • 7. ENGINEERS AND DEVICES WORKING TOGETHER Android Marshmallow Ahead-Of-Time (AOT) Solution APK INSTALL (AOT) Native Code START APP Fast startup performanceMore Storage Required Slow Installation Fast runtime performance Less runtime battery consumption 7
  • 8. ENGINEERS AND DEVICES WORKING TOGETHER More Challenges for AOT Nowadays APK INSTALL (AOT) Native Code START APP ● System Update Time ● Storage Consumption ● Dynamic APK 8
  • 9. ENGINEERS AND DEVICES WORKING TOGETHER ART Implementation in Android N JITAPK INSTALL DEX Code START APP Native Code AOT Native Code START APP PROFILE Compilation Daemon Service 9
  • 10. ENGINEERS AND DEVICES WORKING TOGETHER ART Implementation in Android N JITAPK INSTALL DEX Code START APP Native Code ● JIT Phase ○ Fast installation ○ Fast system update time (OTA) AOT Native Code START APP Compilation Daemon Service 10
  • 11. ENGINEERS AND DEVICES WORKING TOGETHER ART Implementation in Android N AOT Native Code START APP Compilation Daemon Service ● Profile Guided AOT: ○ Fast startup and runtime performance ○ Lower overheads: CPU, storage, power ... JITAPK INSTALL DEX Code START APP Native Code 11
  • 12. ENGINEERS AND DEVICES WORKING TOGETHER ART JIT - Implementation Overview JITAPK INSTALL DEX Code START APP Native Code ● JIT Runtime ● JIT Compiler ● Generates Profile File 12
  • 13. ENGINEERS AND DEVICES WORKING TOGETHER ART JIT - Implementation Overview JITAPK INSTALL DEX Code START APP Native Code ● JIT Runtime ● JIT Compiler ● Generates Profile File ● Interpreter ○ Computed-goto based ○ Opcode handling in ARM assembly ● Profiling & Triggering JIT Compilation ○ Based on execution count and heuristics ○ ‘hotness_count’ ● JIT Code Cache ○ Manages JITed Code ○ Allocating ‘ProfilingInfo’ for hot methods 13
  • 14. ENGINEERS AND DEVICES WORKING TOGETHER ART JIT - Implementation Overview JITAPK INSTALL DEX Code START APP Native Code ● JIT Runtime ● JIT Compiler ● Generates Profile File ● Method granularity compilation ● Background compilation. ○ Avoid blocking APP thread (e.g. UI thread) ● Based on ART optimizing compiler. ○ Same compiler used for AOT compilation. ● JIT compilation enhancements in optimizing compiler 14
  • 15. ENGINEERS AND DEVICES WORKING TOGETHER ART JIT - Implementation Overview JITAPK INSTALL DEX Code START APP Native Code ● JIT Runtime ● JIT Compiler ● Generates Profile File● ProfileSaver thread ○ Reads ‘ProfilingInfo’ about hot methods ○ Writes such info to disk ● Minimize overhead ○ Wakeup frequency ○ Minimize things to write 15
  • 16. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode ● Idea of Hybrid Mode (JIT + AOT) ….. ….. 16
  • 17. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode ● Idea of Hybrid Mode (JIT + AOT) ○ Some users only use part of the APP. Only these frequently used features (and code behind them) are worth compiling into native code. ….. ….. 17
  • 18. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode ● Idea of Hybrid Mode (JIT + AOT) ○ Some users only use part of the APP. Only frequently used features (and code behind them) are worth compiling into native code. ○ Use JIT phase to find out the frequently used code. ….. ….. 18
  • 19. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode ● Idea of Hybrid Mode (JIT + AOT) ○ Some users only use part of the APP. Only frequently used features (and code behind them) are worth compiling into native code. ○ Use JIT phase to find out the frequently used code. ○ Use AOT compilation & optimization to speed up frequent use cases. ….. ….. 19
  • 20. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode ● Idea of Hybrid Mode (JIT + AOT) ○ Some users only use part of the APP. Only frequently used features (and code behind them) are worth compiling into native code. ○ Use JIT phase to find out the frequently used code. ○ Use AOT compilation & optimization to speed up frequent use cases. ○ Avoid paying overheads (compilation, storage, etc) to those less used codes. ….. ….. 20
  • 21. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode - Overview ● Implementation ○ Generate Offline Profile During JIT ○ Offline Profile File Format ○ Enhanced AOT Compiler (dex2oat) ○ Compilation Daemon Service ….. ….. 21
  • 22. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode base.apk methods: 1,2,5 classes: 0,6,13 base.apk:classes2.dex methods: 5,12,28 classes: 17,19,33 JITAPK INSTALL DEX Code START APP Native Code PROFILE Offline Profile File ● Each APP has its own profile. ● Stored in APP local storage. ● Simple format. ● Analysis through profman tool. 22
  • 23. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode ● Compilation Daemon ○ Triggers AOT when the device is charging and idle. ○ ‘BackgroundDexOptService’ ○ frameworks/base/services/core/java/com/android/server/pm/ ….. ….. AOT Native Code Compilation Daemon Service 23
  • 24. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode JITAPK INSTALL DEX Code START APP Native Code PROFILE Profile Guided AOT ● dex2oat enhanced to accept profile ● selective compilation based on profile AOT Native Code START APP Compilation Daemon Service dex2oat32 I compiler_driver.cc Skipped method:void MyClass.<init>() dex2oat32 I compiler_driver.cc Compiled method:int MyClass.foo(int) dex2oat32 I compiler_driver.cc Compiled method:void MyClass.main() dex2oat32 I compiler_driver.cc Skipped method:boolean MyClass.verify() dex2oat32 I compiler_driver.cc Skipped method:void Class2.<init>() 24
  • 25. ENGINEERS AND DEVICES WORKING TOGETHER ART Hybrid Mode ● Run in Hybrid Mode ○ All previous ‘hot’ methods are AOT compiled ○ JIT compiler is still loaded in memory ■ For unexplored features/codes. ■ May generate new profiles. ….. ….. 25
  • 26. ENGINEERS AND DEVICES WORKING TOGETHER Tools ● TraceView (Android Studio / Android SDK) 26
  • 27. ENGINEERS AND DEVICES WORKING TOGETHER Tools ● Systrace (Android Studio / Android SDK) ○ Enable 'dalvik' trace ○ Analyze JIT behaviors: JIT code cache, ProfilerSaver, GC, etc. ○ Helps to measure: i. Invoke Time (1, 5, 6) ii. JIT compilation time for each method (2, 3) iii. JITed code execution (4) 27
  • 28. ENGINEERS AND DEVICES WORKING TOGETHER Tools ● JIT Compiler Analysis ○ CFG dump ■ CFG file analysis: ○ Profiling JITed code ■ Support generating /tmp/perf-PID-maps for method level profiling with perf. ■ Profile AOT compiled code is prefered, for instruction level profiling. ○ Other useful JIT statistics & logs: ■ -verbose:compiler, -verbose:jit ■ -XX:DumpJITInfoOnShutdown dalvikvm -Xusejit:true -Xcompiler-option --dump-cfg=jit.cfg -cp Main.dex Main 28
  • 29. ENGINEERS AND DEVICES WORKING TOGETHER Tools ● Profile Guided AOT Analysis - profman profman --profile-file=<filename> --dump-only This command can dump the contents in the given prof file. profman --generate-test-profile=<filename> This command can generate a random profile file for testing. runtime/jit/offline_profiling_info.cc // Debug flag to ignore checksums when testing. // Used to facilitate testing across a large number of apps. static constexpr bool kDebugIgnoreChecksum = true; compiler/driver/compiler_driver.cc // Print additional info during profile guided compilation. static constexpr bool kDebugProfileGuidedCompilation = true; 29
  • 30. ENGINEERS AND DEVICES WORKING TOGETHER Performance & Findings ● A Popular News Reader APP 30
  • 31. ENGINEERS AND DEVICES WORKING TOGETHER Performance & Findings ● A Popular News Reader APP 31
  • 32. ENGINEERS AND DEVICES WORKING TOGETHER Performance & Findings ● Micro Benchmark Performance, AOT vs. JIT 32
  • 33. ENGINEERS AND DEVICES WORKING TOGETHER More Talks & Resources ● Linaro-ART Team: ○ VIXL: A Programmatic Assembler and Disassembler for AArch32 ○ Android Runtime Performance Analysis ● The Evolution of ART - Google I/O 2016 ○ https://www.youtube.com/watch?v=fwMM6g7wpQ8 ● Implementing ART Just-In-Time (JIT) Compiler ○ http://source.android.com/devices/tech/dalvik/jit-compiler.html 33
  • 34. Thank You #LAS16 For further information: www.linaro.org LAS16 keynotes and videos on: connect.linaro.org 34
  • 35. ENGINEERS AND DEVICES WORKING TOGETHER Backup 35
  • 36. ENGINEERS AND DEVICES WORKING TOGETHER Performance & Findings - Example ● Micro Benchmarking – Running Unexpected Modes void runAlgorithm(int iterations) { for(i=0; i<iterations; i++) { // long operations … } } void main() { int iterations = 20000; int before = time(); runAlgorithm(iterations); int after = time(); // … } 36
  • 37. ENGINEERS AND DEVICES WORKING TOGETHER Performance & Findings - Example ● JIT’s Advantage over AOT – Inlining public class MyClass { public /*private*/ /*final*/ /*static*/ int arithmeticSeries(int i) { if(i == 0) return 0; else return i + arithmeticSeries(i - 1); // invoke-virtual } } 37
  • 38. ENGINEERS AND DEVICES WORKING TOGETHER ART JIT - Workflow 38