Bug 1431755 - Part 3: Remove a redundant dispatch that was causing us to record the duration of _two_ dispatches instead of one. draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 19 Jan 2018 10:03:35 -0600
changeset 750238 f33b74f557d67f45530439ecbd05ff28ffdf03af
parent 750237 806376e676e46e8b34d44940968d82ef5af94933
push id97593
push userbcampen@mozilla.com
push dateThu, 01 Feb 2018 19:52:27 +0000
bugs1431755
milestone60.0a1
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
tools/profiler/gecko/ThreadResponsiveness.cpp
--- 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;
   }