0
Android Overview                    Native code for Android        Benchmarking




           Developing and Benchmarking...
Android Overview                  Native code for Android   Benchmarking




Outline

      1     Android Overview
       ...
Android Overview                  Native code for Android   Benchmarking




Outline

      1     Android Overview
       ...
Android Overview          Native code for Android           Benchmarking


What is Android?


What is Android?



        ...
Android Overview                         Native code for Android                Benchmarking


How does it work?


How doe...
Android Overview                 Native code for Android               Benchmarking


How does it work?


Development of A...
Android Overview          Native code for Android           Benchmarking


The Dalvik VM


The Dalvik VM



              ...
Android Overview                 Native code for Android             Benchmarking


The Dalvik VM




      Why not speed-...
Android Overview                 Native code for Android             Benchmarking


The Dalvik VM




      Why not speed-...
Android Overview                  Native code for Android   Benchmarking




Outline

      1     Android Overview
       ...
Android Overview                    Native code for Android           Benchmarking


Scope


Scope


        What is a goo...
Android Overview                    Native code for Android           Benchmarking


Scope


Scope


        What is a goo...
Android Overview                   Native code for Android                 Benchmarking


Important facts


Important fact...
Android Overview                Native code for Android   Benchmarking


Techniques


Techniques




      JNI
      Java ...
Android Overview                      Native code for Android            Benchmarking


Techniques


JNI


       Java cla...
Android Overview                              Native code for Android          Benchmarking


Techniques


Pipes

       J...
Android Overview                  Native code for Android   Benchmarking




Outline

      1     Android Overview
       ...
Android Overview                                    Native code for Android                  Benchmarking


Performance is...
Android Overview                                       Native code for Android           Benchmarking


Performance issues...
Android Overview                    Native code for Android           Benchmarking


Performance issues


Performance issu...
Android Overview             Native code for Android           Benchmarking


Benchmarking set-up


Microbenchmarking appr...
Android Overview                    Native code for Android       Benchmarking


Benchmarking set-up


Benchmark set-up


...
Android Overview                    Native code for Android       Benchmarking


Benchmarking set-up


Benchmark set-up


...
Android Overview                                Native code for Android                             Benchmarking


Results...
Android Overview                                   Native code for Android                            Benchmarking


Resul...
Android Overview                    Native code for Android              Benchmarking


Conclusions


Conclusions for Andr...
Android Overview                    Native code for Android              Benchmarking


Conclusions


Conclusions for Andr...
Android Overview                    Native code for Android              Benchmarking


Conclusions


Conclusions for Andr...
Android Overview                    Native code for Android              Benchmarking


Conclusions


Conclusions for Andr...
Android Overview                 Native code for Android        Benchmarking


Conclusions


Future work




             ...
Android Overview    Native code for Android   Benchmarking


Conclusions




                   Thank you!
Upcoming SlideShare
Loading in...5
×

Developing and Benchmarking Native Linux Applications on Android

3,354

Published on

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

No Downloads
Views
Total Views
3,354
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
109
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "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 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
  3. 3. 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
  4. 4. Android Overview Native code for Android Benchmarking What 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 Benchmarking How 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 Benchmarking How 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 Benchmarking The Dalvik VM The 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 Benchmarking The 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 Benchmarking The 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 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
  11. 11. Android Overview Native code for Android Benchmarking Scope Scope 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 Benchmarking Scope Scope 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 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
  14. 14. Android Overview Native code for Android Benchmarking Techniques Techniques JNI Java Native Interface Pipes Traditional unixoid IPC via FIFOs
  15. 15. 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
  16. 16. 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
  17. 17. 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
  18. 18. Android Overview Native code for Android Benchmarking Performance issues Performance 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 Benchmarking Performance issues Performance 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 Benchmarking Performance issues Performance 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 Benchmarking Benchmarking set-up Microbenchmarking 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 Benchmarking 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 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 Benchmarking 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 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 Benchmarking Results Results 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 Benchmarking Results Results 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 Benchmarking Conclusions Conclusions 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 Benchmarking Conclusions Conclusions 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 Benchmarking Conclusions Conclusions 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 Benchmarking Conclusions Conclusions 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 Benchmarking Conclusions Future 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 Benchmarking Conclusions Thank you!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×