Isolate statsd_write trace when reporting jank.
Prior benchmarks shows that this should take 2.6-2.7 micros, but there
exist traces showing that the current slice can take ~700 micros, and
even up to 8 milliseconds, which confounds with the debug log that is
also expected to be cheap. There is evidence that logd occasionally
causes preemption in flinger, so isolate the two calls so that the next
time a bad trace comes in we know what the cause is.
Bug: 144289346
Test: builds
Change-Id: I899e9f99107fad1f5e501b783ce57bfd12300b85
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 79ea97b..18fffe2 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1927,8 +1927,11 @@
ATRACE_NAME("Jank detected");
ALOGD("Detected janky event. Missed frames: %d", mMissedFrameJankCount);
const int32_t jankyDurationMillis = jankDuration / (1000 * 1000);
- android::util::stats_write(android::util::DISPLAY_JANK_REPORTED,
- jankyDurationMillis, mMissedFrameJankCount);
+ {
+ ATRACE_NAME("Pushing to statsd");
+ android::util::stats_write(android::util::DISPLAY_JANK_REPORTED,
+ jankyDurationMillis, mMissedFrameJankCount);
+ }
}
// We either reported a jank event or we missed the trace