Profiling and Testing with TPTP

1,984 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,984
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
25
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Profiling and Testing with TPTP

  1. 1. Eclipse* TPTP Project Using Eclipse* TPTP to Visualize Google* Android* Profiling Data ** Chris Elford -- Intel Corporation Yunan He -- Intel Corporation *Other names and brands may be claimed as the property of others. ** Android image from http://www.android.com/media/goodies.html overlaid with the Eclipse TPTP logo Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  2. 2. Eclipse* TPTP Project Outline Android development and SDK from 10,000 feet How profiling in Android is done Enabling profile trace creation Visualizing the trace Problem statement Overview of Eclipse* TPTP Using The Eclipse* TPTP profiler for Android Applications Converting Android Profile data to TPTP format Analysis of simple android workload with TPTP views Next steps Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  3. 3. Eclipse* TPTP Project What is Android* (developer and user perspective) * Apps Managed Framework Native hooks & Managed Runtime Linux Core *Source http://developer.android.com/guide/basics/what-is-android.html Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  4. 4. Eclipse* TPTP Project What is Android* (developer perspective) The DalvikVM : Managed runtime similar to Java* * Same OO development model Architecture specific transforms done opaquely VM automatically recycles no longer referenced items Code is written in Java language Using a subset of Java* APIs plus some Android APIs Compiled with Java compiler foo.java → foo.class Java bytecode is never deployed Converted into DEX bytecode foo.class → foo.dex Register based bytecode instead of stack based bytecode DEX is bundled with a Manifest, signed, and deployed onto a framework Java “main()” is never called for Android Applications Android.App.Activity.onCreate() is the main entry point for many apps *Source http://developer.android.com/guide/basics/what-is-android.html Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  5. 5. Eclipse* TPTP Project Android Profiling Overview : The Android SDK SDK available at developer.android.com Includes build packages, docs, tools, device emulator Three tools in particular DDMS – Dalvik Debug Monitor Service (monitor system, debug apps) ADB – Android debug bridge (shell and other interactions to device) Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  6. 6. Eclipse* TPTP Project Android Profiling Overview : The Android SDK SDK available at developer.android.com Includes build packages, docs, tools, device emulator Three tools in particular DDMS – Dalvik Debug Monitor Service (monitor system, debug apps) ADB – Android debug bridge (shell and other interactions to device) Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  7. 7. Eclipse* TPTP Project Android Profiling Overview : The Android SDK The de-facto IDE is Eclipse (ADT) Source language is Java so development is primarily using JDT Point update manager at https://dl-ssl.google.com/android/eclipse/ Configure location where Android SDK is installed Java perspective now allows you to create Android projects Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  8. 8. Eclipse* TPTP Project Android Profiling Overview : The Android SDK The de-facto IDE is Eclipse (ADT) New DDMS perspective for interacting with system, debugging, etc Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  9. 9. Eclipse* TPTP Project Android Profiling Overview : Profiling mechanics Choose Activity or Service to profile Insert android.os.Debug.startMethodTracing(…) Anywhere but typically in onCreate(), onStart(), onResume() Insert android.os.Debug.stopMethodTracing() Anywhere but typically onPause(), onStop() Build and run Any old trace will be destroyed Copy trace file protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Debug.startMethodTracing("/data/trace/elf.trace",32*1024*1024); protected void onStop() { super.onStop(); Debug.stopMethodTracing(); } Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  10. 10. Eclipse* TPTP Project Android Profiling Overview : Profiling mechanics View the trace file Traceview – Analyze entry/exit behavior for debug/optimization Standalone Java program. Not integrated with Eclipse * dmtracedump *Source http://developer.android.com/guide/developing/tools/traceview.html#dmtracedump Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  11. 11. Eclipse* TPTP Project Android Profiling Demo - Target By default, Eclipse ADT starts an emulator to run apps Can also connect to actual device Android Open source project has a target for Asus* Eee PC* 701 Development branch; not complete implementation It runs on a range Intel® Atom™ processor based netbooks Target today is slightly tweaked version that Hacks in wifi and power button support for my device Before starting Eclipse Boot target, start wifi, note ip address set ADBHOST=<IP of target> Adb shell to ensure device connection Start Eclipse Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  12. 12. Eclipse* TPTP Project Android Profiling Demo - App Tweaked version of APIDemo SDK Sample* The Text/LogTextBox Activity Remove dependency on MapView APIs Added an easily identifiable performance problem to an Activity Added Profiling start/stop calls *Derived from samplesApiDemos in http://developer.android.com/sdk/1.1_r1 Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  13. 13. Eclipse* TPTP Project Android Profiling Demo Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  14. 14. Eclipse* TPTP Project Wouldn’t it be nice if… Android profiling was integrated into Eclipse ADT We could click on a hotspot and jump to the code We could switch between development and profiling perspectives Eclipse already has a Java profiler (in Eclipse TPTP) Consumes similar data (e.g., Java* method entry/exit traces) Produces similar views to Android traceview (and more) How hard would it be to connect the dots? It seems like there is a match to Eclipse TPTP Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  15. 15. Eclipse* TPTP Project Eclipse* TPTP Profiling Tool Overview Target use cases For performance analysis and deeper understanding of Java* programs Visualization of program execution and threading behavior Pinpointing operations that take most resources Exploring patterns of program behavior For early-in-the-cycle tests of your application Easy to use with extensive GUI’s Profiling and Logging Perspectives A number of graphical and tabular views Low Overhead Enables on-demand profiling by running applications with agent-on at near full speed and later attaching to gather data in various phases Advanced data processing Assorted filtering functionalities to help localize problems and reduce data volume for long running applications Sophisticated input stream analyzer Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  16. 16. Eclipse* TPTP Project Obligatory Eclipse* TPTP Architecture Diagram Presentation System Target System Trace file importer Control Interface Control Interface Eclipse TPTP GUI Allows import of externally Distributed collected trace Trace Analysis and Execution Test Creation Test Engine Agent Agent And Profiling Management Monitor / log Control Runtime Artifact Framework TPTP trcxml format TPTPTestability Interface format binary trace Standard Widgets and TPTP External agents Application Data Collection Core Plug-ins Reference Perspectives Java* JVMPI* Trace Collection And Workflow Java* JVMTI* Log Collection EMF Data Models Real Time Data Loader Statistical Export Execution Data Collection Trace Distributed Test Environment Log Interface Data Collection Injection Framework JVMPI Monitor XMI JVMTI Monitor Correlation System Performance Trace file importer Monitor Eclipse Platform Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  17. 17. Eclipse* TPTP Project Profiling and Logging Perspective Profiling and Logging perspective provides resources For starting a profiling session as well as obtaining comprehensive information on the performance of the monitored application For importing trace file in TPTP format and showing with profiling views Profiling views Visualize and analyze profiling data Execution Statistic view (tabular) Execution Flow view (graphical + tabular) Others… Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  18. 18. Eclipse* TPTP Project Monitor actions Open view actions View level actions Monitor and Navigator view Profiling views Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  19. 19. Eclipse* TPTP Project Initial Approach to using TPTP with Android profiles Use the data conversion tool -- A light weight java application with modular design Get android trace file Provide source and destination file names Run file converter Done! Conversion and visualizing are done “externally”. Users can not use TPTP to directly invoke or interact with running Android apps.. Today… Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  20. 20. Eclipse* TPTP Project Data Conversion Converter File Reader File Writer Parser Emitter EMF Data Model Android Trace File TPTP Trace File Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  21. 21. Eclipse* TPTP Project Data Conversion (cont’d) Android Trace File Format Data file segment, holds the trace data Key file segment, provide a mapping from binary identifier to thread and method names TPTP Trace File Format XML fragments / binary format Full graph mode / aggregating mode Data Fragment Aggregating mode can reduce the data size significantly. * <main entry, main start time > <main entry, main exec time> void main( ) { A( ); C( ); } <A entry, A start time> <A entry, A exec time > void A( ) { B( ); B( ); } <B entry, B1 start time> <B entry, B1+ B2 exec time > void B( ) { } <B exit, B1 end time> <B exit> void C( ) { B( ); } <B entry, B2 start time> <A exit> B1 B2 <B exit, B2 end time> <C entry, C exec time> <A exit, A end time> <B entry, B3 exec time> B3 …. [full graph mode] …. [aggregating mode] Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  22. 22. Eclipse* TPTP Project Data Conversion (cont’d) Map Android trace data to TPTP trace data (full graph mode ) Map directly Thread, Class and Method basic information Method Entry and Exit Calculate from original data Thread start time and etc. Set to arbitrary value AgentId and etc. Map Android trace data to TPTP trace data (aggregating mode ) Map directly Thread, Class and Method basic information Calculate from original data Method execution time Thread start time and etc. Set to arbitrary value AgentId and etc. Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  23. 23. Eclipse* TPTP Project Data Import Import profiling data to eclipse workspace File -> Import Select “profiling file” in profiling and logging folder Fill with file name and choose “show execution statistics” or “show full data” Finish Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  24. 24. Eclipse* TPTP Project Viewing the Data Choose the view suitable for our data (execution statistics view ) Open view Right click data in profiling monitor view. Open With -> Execution Statistics Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  25. 25. Eclipse* TPTP Project Viewing the Data Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  26. 26. Eclipse* TPTP Project Profiling Android App. with TPTP – What’s Next? Definite plans Open source the conversion tool Plan to contribute back to Android Open Source project Solicit user feedback on the TPTP mailing lists/newsgroups Some possible enhancement ideas If there is interest and maybe participants in such a project… TPTP is currently primarily maintenance mode… Looking for new contributors ☺ Hook in more data collectors (memory, thread, etc) Initial experiments primarily on execution analysis (and basic thread views) Memory -- Android.os.debug.startAllocCounting(…)/stopAllocCounting() Thread – More advanced inter-thread passing of control analysis Enable Android Collectors to talk to TPTP* Agent Controller Deploy agent controller on target system (Android) and fetch data directly Avoid conversion overhead Monitor “live” application Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  27. 27. Eclipse* TPTP Project Conclusion Our perspective Android is getting popular and it uses Java in development Eclipse* TPTP supports great Java* code analysis Eclipse* TPTP can visualize the traces collected by Android Profiler It works! It integrates with ADT quite well in initial tests What we would like from you Try Android profiling tools and the converter Tell us about your experience on TPTP mailing lists Try Eclipse* TPTP profiler Tell us about your experience (and feel free to join) Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  28. 28. Eclipse* TPTP Project TPTP Resources (profiling and beyond) Learn and Try and Talk Tuesday TPTP BOF -- 19.30-20.45 -- Room 203/204 Wednesday Profiling and Testing with TPTP -- 15.30-16.20 -- Room 203/204 Linux Extended IDE - Linux Tracing -- 20.00+ -- Room 201 Webs and Wikis http://www.eclipse.org/TPTP http://wiki.eclipse.org/TPTP Downloads and Updates http://www.eclipse.org/tptp/home/downloads http://www.eclipse.org/tptp/home/downloads/updateManager.php News and Mail http://www.eclipse.org/tptp/home/project_info/general/mailnews.php Use and Participate http://wiki.eclipse.org/TPTP_User_Experiences_Profiling http://www.eclipse.org/tptp/home/project_info/general http://wiki.eclipse.org/TPTP_User_Experiences Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  29. 29. Eclipse* TPTP Project Resources: Getting started with Android SDK Download the SDK http://developer.android.com/sdk/index.html Includes device emulator (including skins for different devices) Works on Windows*, Linux, Mac* Provides Eclipse integration (primary and a few other IDE integrations) Read the Developers Guide http://developer.android.com/guide/ Try the Tutorials and Samples http://developer.android.com/guide/tutorials/hello-world.html http://developer.android.com/guide/tutorials/views/index.html http://developer.android.com/guide/tutorials/notepad/index.html http://developer.android.com/guide/samples Bookmark the Documentation http://developer.android.com/reference/ Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  30. 30. Eclipse* TPTP Project Intel, the Intel logo and Atom are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. * Other names and brands may be claimed as the property of others. Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
  31. 31. Eclipse* TPTP Project Questions? Confidential | Date | Other Information, if necessary Using Eclipse* TPTP to visualize Google* Android* Profiling Data © 2002 IBM Corporation © 2009 Intel Corporation; made available under the EPL v1.0 | March 2009

×