Android Overview                    Native code for Android        Benchmarking           Developing and Benchmarking Nati...
Android Overview                  Native code for Android   BenchmarkingOutline      1     Android Overview              W...
Android Overview                  Native code for Android   BenchmarkingOutline      1     Android Overview              W...
Android Overview          Native code for Android           BenchmarkingWhat is Android?What is Android?                  ...
Android Overview                         Native code for Android                BenchmarkingHow does it work?How does it w...
Android Overview                 Native code for Android               BenchmarkingHow does it work?Development of Android...
Android Overview          Native code for Android           BenchmarkingThe Dalvik VMThe Dalvik VM                   Custo...
Android Overview                 Native code for Android             BenchmarkingThe Dalvik VM      Why not speed-up using...
Android Overview                 Native code for Android             BenchmarkingThe Dalvik VM      Why not speed-up using...
Android Overview                  Native code for Android   BenchmarkingOutline      1     Android Overview              W...
Android Overview                    Native code for Android           BenchmarkingScopeScope        What is a good reason ...
Android Overview                    Native code for Android           BenchmarkingScopeScope        What is a good reason ...
Android Overview                   Native code for Android                 BenchmarkingImportant factsImportant facts     ...
Android Overview                Native code for Android   BenchmarkingTechniquesTechniques      JNI      Java Native Inter...
Android Overview                      Native code for Android            BenchmarkingTechniquesJNI       Java class       ...
Android Overview                              Native code for Android          BenchmarkingTechniquesPipes       Java clas...
Android Overview                  Native code for Android   BenchmarkingOutline      1     Android Overview              W...
Android Overview                                    Native code for Android                  BenchmarkingPerformance issue...
Android Overview                                       Native code for Android           BenchmarkingPerformance issuesPer...
Android Overview                    Native code for Android           BenchmarkingPerformance issuesPerformance issues of ...
Android Overview             Native code for Android           BenchmarkingBenchmarking set-upMicrobenchmarking approach  ...
Android Overview                    Native code for Android       BenchmarkingBenchmarking set-upBenchmark set-up         ...
Android Overview                    Native code for Android       BenchmarkingBenchmarking set-upBenchmark set-up         ...
Android Overview                                Native code for Android                             BenchmarkingResultsRes...
Android Overview                                   Native code for Android                            BenchmarkingResultsR...
Android Overview                    Native code for Android              BenchmarkingConclusionsConclusions for Android   ...
Android Overview                    Native code for Android              BenchmarkingConclusionsConclusions for Android   ...
Android Overview                    Native code for Android              BenchmarkingConclusionsConclusions for Android   ...
Android Overview                    Native code for Android              BenchmarkingConclusionsConclusions for Android   ...
Android Overview                 Native code for Android        BenchmarkingConclusionsFuture work              Port a mor...
Android Overview    Native code for Android   BenchmarkingConclusions                   Thank you!
Upcoming SlideShare
Loading in …5
×

Developing and-benchmarking-native-linux-applications-on-android

548 views
494 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
548
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Developing and-benchmarking-native-linux-applications-on-android

  1. 1. Android Overview Native code for Android Benchmarking Developing and Benchmarking Native Linux Applications on Android Leonid Batyuk Aubrey-Derrick Schmidt Hans-Gunther Schmidt Ahmet Camtepe Sahin Albayrak DAI-Labor, Technische Universität Berlin The Second International ICST Conference on MOBILe Wireless MiddleWARE, Operating Systems, and Applications, 2009
  2. 2. Android Overview Native code for Android BenchmarkingOutline 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
  3. 3. Android Overview Native code for Android BenchmarkingOutline 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
  4. 4. Android Overview Native code for Android BenchmarkingWhat is Android?What is Android? Android is an open-source OS for mobile internet devices Android is being driven by the Open Handset Alliance, including Google, HTC, T-Mobile, Samsung, Sony-Ericsson, Motorola and others Android is tageted at, but not limited to smartphones. It is supposed for all kinds of mobile devices, including netbooks
  5. 5. Android Overview Native code for Android BenchmarkingHow does it work?How does it work? Android comprises of: Application Linux kernel Application Framework Modified BSD libc (bionic) Stripped-down unixoid userland Libraries Dalvik VM Custom object oriented IPC Linux kernel (OpenBinder) Custom Java VM (Dalvik)
  6. 6. Android Overview Native code for Android BenchmarkingHow does it work?Development of Android applications Developers are intended to create Manifest file applications in Java Dalvik bytecode An SDK is provided by Google Emulator Eclipse plugin GUI styles Debugging utilities GUI layout An application is packaged for distribution in an APK file, which contains: Localization Bytecode Manifest file describing the capabilities etc. Resources Various application resources APK Distribution is possible, but not restricted to, the Android Market.
  7. 7. Android Overview Native code for Android BenchmarkingThe Dalvik VMThe Dalvik VM Custom Java VM developed by Google Uses its own bytecode, not Java bytecode Each application runs in its own VM instance for security reasons Register-based, optimized for small footprint Lacks Just-In-Time compilation and other common optimizations, therefore not performant
  8. 8. Android Overview Native code for Android BenchmarkingThe Dalvik VM Why not speed-up using native code? Using native code is still not supported, but is expected to become part of the SDK by the end of the year. Google says: [...] C/C++ code [...] easily runs 10-100x faster than doing the same thing in a Java loop.
  9. 9. Android Overview Native code for Android BenchmarkingThe Dalvik VM Why not speed-up using native code? Using native code is still not supported, but is expected to become part of the SDK by the end of the year. Google says: [...] C/C++ code [...] easily runs 10-100x faster than doing the same thing in a Java loop.
  10. 10. Android Overview Native code for Android BenchmarkingOutline 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
  11. 11. Android Overview Native code for Android BenchmarkingScopeScope What is a good reason to use native code? Speed up heavy computational tasks Time-critical applications Running a daemon outside of the application lifecycle 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
  12. 12. Android Overview Native code for Android BenchmarkingScopeScope What is a good reason to use native code? Speed up heavy computational tasks Time-critical applications Running a daemon outside of the application lifecycle 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
  13. 13. Android Overview Native code for Android BenchmarkingImportant factsImportant 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
  14. 14. Android Overview Native code for Android BenchmarkingTechniquesTechniques JNI Java Native Interface Pipes Traditional unixoid IPC via FIFOs
  15. 15. Android Overview Native code for Android BenchmarkingTechniquesJNI 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
  16. 16. Android Overview Native code for Android BenchmarkingTechniquesPipes 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
  17. 17. Android Overview Native code for Android BenchmarkingOutline 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
  18. 18. Android Overview Native code for Android BenchmarkingPerformance issuesPerformance of the Sun JVM Linux x86 PC (for comparison) 1.5 Time elapsed [ms] 1 0.5 Sun JRE 1.6 0 gcc -O3 0 2,000 4,000 Array size
  19. 19. Android Overview Native code for Android BenchmarkingPerformance issuesPerformance issues of the Dalvik VM Android emulator Dalvik VM Android C Time elapsed [ms] 100 50 0 0 2,000 4,000 Array size
  20. 20. Android Overview Native code for Android BenchmarkingPerformance issuesPerformance issues of the Dalvik VM Dalvik performance problems No Just-in-Time compilation Optimized for small footprint, not raw performance Java I/O (java.io) and built-in functions relatively slow
  21. 21. Android Overview Native code for Android BenchmarkingBenchmarking set-upMicrobenchmarking approach Microbenchmarking focuses on small and uncomplicated benchmarks Measuring the performance of the basic computing operations Not intended to rate the overall performance of the system Not measuring the responsiveness of the UI or the I/O speed
  22. 22. Android Overview Native code for Android BenchmarkingBenchmarking set-upBenchmark 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 Setup on Android and on a Linux PC Android: Code Sourcery gcc -O3 vs. Dalvik VM Linux: GNU Compiler Collection gcc -O3 vs. Sun JDK 1.6
  23. 23. Android Overview Native code for Android BenchmarkingBenchmarking set-upBenchmark 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 Setup on Android and on a Linux PC Android: Code Sourcery gcc -O3 vs. Dalvik VM Linux: GNU Compiler Collection gcc -O3 vs. Sun JDK 1.6
  24. 24. Android Overview Native code for Android BenchmarkingResultsResults on Android Sorting Integers on Android 103 Time elapsed [ms] 102 pipe (using native Linux) 101 plain Java heapsort (VM) PriorityQueue (VM) Java built-in (VM) 100 JNI (using native Linux) 0 1,000 2,000 3,000 4,000 5,000 Array size
  25. 25. Android Overview Native code for Android BenchmarkingResultsResults on a Linux system (for comparison) Sorting Integers on a Linux PC (for comparison) 101 Time elapsed [ms] 100 pipe (using native Linux) 10−1 heapsort (VM) PriorityQueue (VM) Java built-in (VM) JNI (using native Linux) 10−2 0 1,000 2,000 3,000 4,000 5,000 Array size
  26. 26. Android Overview Native code for Android BenchmarkingConclusionsConclusions for Android JNI is the fastest approach JNI is up to 10 times faster than plain Java Pipes are unfeasible for data-intensive tasks because of the expensive I/O Google should optimize Dalvik: introduce JIT implement computationally complex classpath methods with JNI
  27. 27. Android Overview Native code for Android BenchmarkingConclusionsConclusions for Android JNI is the fastest approach JNI is up to 10 times faster than plain Java Pipes are unfeasible for data-intensive tasks because of the expensive I/O Google should optimize Dalvik: introduce JIT implement computationally complex classpath methods with JNI
  28. 28. Android Overview Native code for Android BenchmarkingConclusionsConclusions for Android JNI is the fastest approach JNI is up to 10 times faster than plain Java Pipes are unfeasible for data-intensive tasks because of the expensive I/O Google should optimize Dalvik: introduce JIT implement computationally complex classpath methods with JNI
  29. 29. Android Overview Native code for Android BenchmarkingConclusionsConclusions for Android JNI is the fastest approach JNI is up to 10 times faster than plain Java Pipes are unfeasible for data-intensive tasks because of the expensive I/O Google should optimize Dalvik: introduce JIT implement computationally complex classpath methods with JNI
  30. 30. Android Overview Native code for Android BenchmarkingConclusionsFuture work Port a more common benchmark to Android (maybe LINPACK) Benchmark various handsets as they emerge during 2009 Compare performance of Android to other mobile OSes on the same hardware
  31. 31. Android Overview Native code for Android BenchmarkingConclusions Thank you!

×