Professional Documents
Culture Documents
Outline
1 Android Overview
What is Android?
How does it work?
The Dalvik VM
2 Native code for Android
Scope
Important facts
Techniques
3 Benchmarking
Performance issues
Benchmarking set-up
Results
Conclusions
Android Overview Native code for Android Benchmarking
Outline
1 Android Overview
What is Android?
How does it work?
The Dalvik VM
2 Native code for Android
Scope
Important facts
Techniques
3 Benchmarking
Performance issues
Benchmarking set-up
Results
Conclusions
Android Overview Native code for Android Benchmarking
What is Android?
What is Android?
The Dalvik VM
The Dalvik VM
The Dalvik VM
Google says:
[...] C/C++ code [...] easily runs 10-100x faster than doing the
same thing in a Java loop.
Android Overview Native code for Android Benchmarking
The Dalvik VM
Google says:
[...] C/C++ code [...] easily runs 10-100x faster than doing the
same thing in a Java loop.
Android Overview Native code for Android Benchmarking
Outline
1 Android Overview
What is Android?
How does it work?
The Dalvik VM
2 Native code for Android
Scope
Important facts
Techniques
3 Benchmarking
Performance issues
Benchmarking set-up
Results
Conclusions
Android Overview Native code for Android Benchmarking
Scope
Scope
Out of scope:
100% native applications are impossible since the UI runs
in Dalvik
Porting big and powerful software like Snort or MySQL is
unfeasible due to linking issues
Android Overview Native code for Android Benchmarking
Scope
Scope
Out of scope:
100% native applications are impossible since the UI runs
in Dalvik
Porting big and powerful software like Snort or MySQL is
unfeasible due to linking issues
Android Overview Native code for Android Benchmarking
Important facts
Important facts
Manifest file
Toolchain
Dalvik bytecode Code Sourcery G++ (G++-like toolchain)
Scratchbox (ARM emulation with a toolchain)
Native binary Different page alignment
Dynamic linking becomes difficult
Native library
Static linking preferred for standalone
GUI styles
executables
Packaging
GUI layout If you want a UI, make your native code a
part of an APK
Localization
Size limit
Resources Any raw resource which is packaged inside
an APK may not exceed 1Mb
APK
Android Overview Native code for Android Benchmarking
Techniques
Techniques
JNI
Java Native Interface
Pipes
Traditional unixoid IPC via FIFOs
Android Overview Native code for Android Benchmarking
Techniques
JNI
Java class
JNI - Java Native Interface
method
Widely accepted in the Java ecosystem
method
(Eclipse, SWT)
native method stub
Widely used in the Android OS
Java implementation
Native Currently not supported in the SDK, but
planned
native function
Runs in same thread, no process is being
C library spawned
Android Overview Native code for Android Benchmarking
Techniques
Pipes
Java class
FIFO - first in, first out
method
Widely used for simple IPC on unixoid
native method stub systems
Java uses a named pipe to communicate to a
Java I/O
Java standalone native executable
FIFO FIFO Java I/O is extremely expensive on Android
Native and thus a bottleneck
Native I/O
Runs in its own thread, can be made a
daemon
native function
This allows us to avoid the standard
C library application lifecycle
Android Overview Native code for Android Benchmarking
Outline
1 Android Overview
What is Android?
How does it work?
The Dalvik VM
2 Native code for Android
Scope
Important facts
Techniques
3 Benchmarking
Performance issues
Benchmarking set-up
Results
Conclusions
Android Overview Native code for Android Benchmarking
Performance issues
1.5
Time elapsed [ms]
0.5
Performance issues
Android emulator
Dalvik VM
Android C
Time elapsed [ms]
100
50
0 2,000 4,000
Array size
Android Overview Native code for Android Benchmarking
Performance issues
Benchmarking set-up
Microbenchmarking approach
Benchmarking set-up
Benchmark set-up
Heapsort in Java
Heapsort in a daemon which listenes to a FIFO
Heapsort in a JNI library
Built-in Java method for sorting arrays
Built-in Java method for sorting objects (PriorityQueue)
Quicksort in Java
Benchmarking set-up
Benchmark set-up
Heapsort in Java
Heapsort in a daemon which listenes to a FIFO
Heapsort in a JNI library
Built-in Java method for sorting arrays
Built-in Java method for sorting objects (PriorityQueue)
Quicksort in Java
Results
Results on Android
103
Time elapsed [ms]
102
Results
101
Time elapsed [ms]
100
Conclusions
Conclusions
Conclusions
Conclusions
Conclusions
Future work
Conclusions
Thank you!