Bug 1431755 - Part 3: Remove a redundant dispatch that was causing us to record the duration of _two_ dispatches instead of one.
MozReview-Commit-ID: E8lSvMbGjt6
--- a/tools/profiler/gecko/ThreadResponsiveness.cpp
+++ b/tools/profiler/gecko/ThreadResponsiveness.cpp
@@ -73,19 +73,26 @@ public:
}
nsresult Cancel() override
{
// No special work needed.
return NS_OK;
}
- // Only runs on the thread being profiled
+ // Only runs on the thread being profiled. Always called via a thread
+ // dispatch, so inherently functions as a responsiveness statistic.
NS_IMETHOD Run() override
{
+ // This approach means that the 16ms delay in the timer below, _plus_ any
+ // additional delays in the TimerThread itself, become part of the
+ // responsiveness statistic for this thread. What we should probably be
+ // doing is recording responsiveness only when we have dispatched (but not
+ // executed) a call to this function, either because of a call to
+ // DoFirstDispatchIfNeeded, or a call to Notify.
mStartToPrevTracer_us = uint64_t(profiler_time() * 1000.0);
if (!mStop) {
if (!mTimer) {
if (mIsMainThread) {
mTimer = NS_NewTimer(
SystemGroup::EventTargetFor(TaskCategory::Other));
} else {
@@ -96,17 +103,17 @@ public:
}
return NS_OK;
}
// Should always fire on the thread being profiled
NS_IMETHOD Notify(nsITimer* aTimer) final override
{
- mThread->Dispatch(this, nsIThread::NS_DISPATCH_NORMAL);
+ Run();
return NS_OK;
}
// Can be called on any thread.
void Terminate() {
mStop = true;
}