More Related Content Similar to Analyzing Display and Performance with Systrace Similar to Analyzing Display and Performance with Systrace (20) More from Rouyun Pan (13) Analyzing Display and Performance with Systrace2. What is Systrace
• The Systrace tool helps analyze the
performance of your application by capturing
and displaying execution times of your
applications processes and other Android
system processes.
3. Command Line Usage
• Android 4.3 and higher options
$ cd $(project)/extenal/chromium-trace/
$ python systrace.py --time=10 -o mynewtrace.html –b 2048 sched gfx view wm
4. ATRACE
• Path
– frameworks/native/cmds/atrace/atrace.cpp
• Define (form system/core/include/cutils/trace.h)
– #define ATRACE_TAG ATRACE_TAG_GRAPHICS
• Function
– ATRACE_CALL()
• Variables
– ATRACE_INT(“Name”, Value);
– ATRACE_INT64(“Name”, Value64);
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
…
Void Function(){
ATRACE_CALL();
int value = 0;
value = Random();
ATRACE_INT(“RandomValue”, value);
}
…
7. CPU Scheduling
• $ python systrace.py --time=10 -o mynewtrace.html sched gfx view wm freq
10. Vsync_On
@EventThread.cpp
Vector< sp<EventThread::Connection> EventThread::waitForEvent(…){
…
if (timestamp && !waitForVSync) {
disableVSyncLocked();
} else if (!timestamp && waitForVSync) {
enableVSyncLocked();
}
…
}
@Sufaceflinger.cpp
virtual void setVSyncEnabled(bool enable) {
if (enable) {
status_t err = mDispSync->addEventListener(mPhaseOffset, static_cast<DispSync::Callback*>(this));
…
ATRACE_INT("VsyncOn", 1);
} else {
status_t err = mDispSync->removeEventListener(static_cast<DispSync::Callback*>(this));
…
ATRACE_INT("VsyncOn", 0);
}
}
12. Vsync
@DispSync.cpp
virtual bool threadLoop() {
while (true) {
…
if (callbackInvocations.size() > 0) {
fireCallbackInvocations(callbackInvocations);
}
…
}…
}
@Surfacefliger.cpp
virtual void onDispSyncEvent(nsecs_t when)
{
sp<VSyncSource::Callback> callback;
{
Mutex::Autolock lock(mMutex);
callback = mCallback;
if (mTraceVsync) {
mValue = (mValue + 1) % 2;
ATRACE_INT("VSYNC", mValue);
}
}
if (callback != NULL) {
callback->onVSyncEvent(when);
}
}
@DispSync.cpp
void fireCallbackInvocations(…) {
for (size_t i = 0; i < callbacks.size(); i++) {
callbacks[i].mCallback-
>onDispSyncEvent(callbacks[i].mEventTime);
}
}
13. HW_Vsync0
Need HW Vsync
@HWComposer.cpp
void vsync(int disp, int64_t timestamp) {
…
char tag[16];
snprintf(tag, sizeof(tag), "HW_VSYNC_%1u", disp);
ATRACE_INT(tag, ++mVSyncCounts[disp] & 1);
mEventHandler.onVSyncReceived(disp, timestamp);
…
}
14. HW_Vsync0
@Surfaceflinger.cpp
void surfaceflinger::onVSyncReceived(){
if (type == 0 && mPrimaryHWVsyncEnabled) {
needsHwVsync = mPrimaryDispSync.addResyncSample(timestamp);
}
if (needsHwVsync) {
enableHardwareVsync();
} else {
disableHardwareVsync(false);
}…
}
@Surfaceflinger.cpp
voidsurfaceflinger::onScreenAcquired(){
…
mEventThread->onScreenAcquired();
resyncToHardwareVsync(true); …
}
@Surfaceflinger.cpp
void surfaceflinger:: onScreenReleased(){
…
if (type== DisplayDevice::DISPLAY_PRIMARY) {
disableHardwareVsync(true);
} …
}