profiling and testing with tptp
DESCRIPTION
TRANSCRIPT
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Using Eclipse* TPTP to Visualize Google* Android* Profiling Data
Chris Elford -- Intel CorporationYunan 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
**
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
What is Android* (developer and user perspective)
Linux Core
Native hooks&
Managed Runtime
Managed Framework
Apps
*Source http://developer.android.com/guide/basics/what-is-android.html
*
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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
*
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Android Profiling Overview : The Android SDKSDK 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)
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Android Profiling Overview : The Android SDKSDK 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)
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Android Profiling Overview : The Android SDKThe 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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Android Profiling Overview : The Android SDKThe de-facto IDE is Eclipse (ADT)
� New DDMS perspective for interacting with system, debugging, etc
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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();
}
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Android Profiling Overview : Profiling mechanicsView 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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Android Profiling Demo - TargetBy 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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Android Profiling Demo - AppTweaked 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 samples\ApiDemos in http://developer.android.com/sdk/1.1_r1
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Android Profiling Demo
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
� Trace file importer
� Allows import of externally
collected trace
� TPTP trcxml format
� TPTP binary trace format
� TPTP External agents
� Java* JVMPI*
� Java* JVMTI*
Trace file importer
Obligatory Eclipse* TPTP Architecture Diagram
Presentation System
Test
Trace
EMF Data Models
Log
StatisticalXMI
Real TimeExport
Runtim
eM
onito
r / log
Trace A
nalysis
And P
rofilin
g
Test C
reation
and E
xecutio
n
Artifact
Man
agem
ent
Eclipse TPTP GUI
Standard Widgets and
Core Plug-ins
Reference Perspectives
And Workflow
Data L
oad
er
Eclipse Platform
Target System
Data C
ollectio
n
Application
Data C
ollectio
n
Interface
InjectionC
orrelation
ExecutionEnvironment
Log Collection
Trace Collection
System PerformanceMonitor
JVMPI Monitor
DistributedData Collection
Framework
Agen
tC
ontro
l Interface
Agen
tC
ontro
l Interface
DistributedControl
Framework
Testability Interface
Test Engine
JVMTI Monitor
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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…
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Open view actions
Monitor and Navigator view Profiling views
View level actionsMonitor actions
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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…
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Data Conversion
EMF Data Model
Parser Emitter
File Reader File Writer
Converter
Android Trace File TPTP Trace File
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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
� Aggregating mode can reduce the data size significantly. *
<main entry, main start time >
<A entry, A start time>
<B entry, B1 start time>
<B exit, B1 end time>
<B entry, B2 start time>
<B exit, B2 end time>
<A exit, A end time>
…. [full graph mode]
<main entry, main exec time>
<A entry, A exec time >
<B entry, B1+ B2 exec time >
<B exit>
<A exit>
<C entry, C exec time>
<B entry, B3 exec time>
…. [aggregating mode]
void main( ) { A( ); C( ); }
void A( ) { B( ); B( ); }
void B( ) { }
void C( ) { B( ); }B1 B2
B3
Data Fragment
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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.
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Viewing the Data
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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)
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Resources: Getting started with Android SDKDownload 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/
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
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.
© 2002 IBM Corporation
Confidential | Date | Other Information, if necessary
Eclipse* TPTP Project
Using Eclipse* TPTP to visualize Google* Android* Profiling Data
© 2009 Intel Corporation; made available under the EPL v1.0 | March 2009
Questions?