Intel® VTune™ Amplifier 2015 Beta for Systems contains a new feature to put Android framework events on the timeline. This information provided is similar to information that the Systrace tool from Google will give you – but with some added GUI flexibility. This allows users of VTune Amplifier to draw correlations between code running on the CPU (and other data collected by VTune Amplifier), and events spawned by the Android framework. One common usage of this feature is to look for "Jank" = dropped frames to support Google's "Project Butter" which is to make the Android OS and apps smoother.
This article provides an example of the Android frameworks feature and it's capability but uses it to find apps that aren't handling Android Application Lifecycle "pause" events, which can help with Google's "Project Volta" to increase device battery performance. In the image below, you can see that this application received an “activityPause” in the Tasks and Frame tab, and that the AsyncTask #1 thread for this application continued to execute code as there is significant "CPU Time" attributed to that thread. Note: On the Android device this is when the “home” button is pressed, which put the application in the background, typically applications should stop executing code when they receive a pause event, and they should save the state of their application, to be resumed once the application receives a resume event.
Now select the region of code after the activityPause until the activityResume and then click "Zoom In and Filter in by Selection" on the code that was executing in AsyncTask #1.
Now switch to the Bottom Up tab, where the code which was executing after the activityPause occurred is displayed.
In this case, there are two functions CalculatePiInJava and CalcultePiinJNI. By double clicking on those functions – you will find these are loops that continue to Calculate Pi until they succeed, and they don’t have an interrupt handler or other mechanism to detect if the activityPause event occurs, and handle it gracefully. See http://developer.android.com/training/basics/activity-lifecycle/pausing.html for information on how to write code to handle the pause event.
To showcase more features of VTune Amplifier, and to see yet another issue... On the timeline in the Tasks and Frame tab you can find an activityStop that really should have been responded to, for fear the application could have been killed prematurely without properly saving the current state of the program. The following screen shot shows that you can zoom in and look at events in more detail, and that you can organize the threads in the Tasks and Frame tab by clicking on a thread in that view and dragging it up or down.
This is just one use case scenario of the Android framework events. There are many other lectures and forums on the internet that explain how to use these Android framework events. But what Intel VTune Amplifier 2015 beta for Systems gives you is a much more flexible GUI and the ability to associate the Android framework events with other data collected on the system via VTune Amplifier for Systems.
The way to get the Android Framework Events in VTune Amplifier 2015 Beta is to create a new Custom Analysis in VTune Amplifier 2015 beta for Systems. The easiest way is to copy from one of the current analysis types… image below:
And then add which type of framework events you want to see in the new Android framework events control.
This dialog accepts a comma delimited list of events (without spaces), as specified in the help associated with this control. Potential events include: gfx,input,view,webview,wm,am,audio,video,camera,hal,res,dalvik.
- gfx - Graphics
- input - Input
- view - View
- webview - WebView
- wm - Window Manager
- am - Activity Manager (The option needed for Activity Lifecycle Events)
- audio - Audio
- video - Video
- camera - Camera
- hal - Hardware Modules
- res - Resource Loading
- dalvik - Dalvik VM
You can also collect via the command Line by adding the following
-knob ftrace-config=event[,event] as explained in the help on the Command Line "knob" option.
amplxe-cl -collect-with runss -target-system=android -knob sampling-interval=2 -knob cpu-samples-mode=stack -knob ftrace-config=gfx,dalvik -knob chipset-event-config="GMCH_PARTIAL_WR_DRAM.ANY,GMCH_CORE_CLKS" --target-process com.intel.tbb.example.tachyon
Future Link to Help