Bug 1504347 - Add IDLE markers and AUTO_PROFILER_THREAD_SLEEP around Necko waits - r=mayhemer

IDLE markers help with categorizing threads in the profiler UI.
_SLEEP makes the profiler spend less time sampling threads that haven't changed.

Differential Revision: https://phabricator.services.mozilla.com/D10815

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gerald Squelart 2018-11-05 12:58:51 +00:00
parent 2bde324acf
commit 69cacfa74d
2 changed files with 12 additions and 1 deletions

View File

@ -576,7 +576,16 @@ nsSocketTransportService::Poll(TimeDuration *pollDuration,
SOCKET_LOG((" timeout = %i milliseconds\n",
PR_IntervalToMilliseconds(pollTimeout)));
int32_t rv = PR_Poll(pollList, pollCount, pollTimeout);
int32_t rv = [&]() {
if (pollTimeout != PR_INTERVAL_NO_WAIT) {
// There will be an actual non-zero wait, let the profiler record
// idle time and mark thread as sleeping around the polling call.
AUTO_PROFILER_LABEL("nsSocketTransportService::Poll", IDLE);
AUTO_PROFILER_THREAD_SLEEP;
return PR_Poll(pollList, pollCount, pollTimeout);
}
return PR_Poll(pollList, pollCount, pollTimeout);
}();
if (mTelemetryEnabledPref && !pollStart.IsNull()) {
*pollDuration = TimeStamp::NowLoRes() - pollStart;

View File

@ -525,6 +525,8 @@ loopStart:
break;
}
AUTO_PROFILER_LABEL("CacheIOThread::ThreadFunc::Wait", IDLE);
AUTO_PROFILER_THREAD_SLEEP;
lock.Wait();
} while (true);