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
This commit is contained in:
Alec Mouri 2020-05-08 19:13:01 -07:00
parent 5a1f549845
commit 30843e3b4d

View file

@ -1927,9 +1927,12 @@ void SurfaceFlinger::onMessageInvalidate(nsecs_t expectedVSyncTime) NO_THREAD_SA
ATRACE_NAME("Jank detected");
ALOGD("Detected janky event. Missed frames: %d", mMissedFrameJankCount);
const int32_t jankyDurationMillis = jankDuration / (1000 * 1000);
{
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
// window, so clear counters here.