Bug 1378975 - label the profiler's ThreadResponsiveness runnables; r=billm
authorNathan Froyd <froydnj@mozilla.com>
Tue, 25 Jul 2017 11:17:32 -0400
changeset 419588 a18e17f0c0b6d08a8817c3e00a5a9e87130c6cca
parent 419587 979cc414d80a9964cb62ff03b72859e5fcb20a40
child 419589 67f6a4e27d5d8cb08f97950c305d1f85e3f585f7
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1378975
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1378975 - label the profiler's ThreadResponsiveness runnables; r=billm
tools/profiler/gecko/ThreadResponsiveness.cpp
--- a/tools/profiler/gecko/ThreadResponsiveness.cpp
+++ b/tools/profiler/gecko/ThreadResponsiveness.cpp
@@ -4,19 +4,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ThreadResponsiveness.h"
 #include "platform.h"
 #include "nsComponentManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "nsITimer.h"
 #include "mozilla/Mutex.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/SystemGroup.h"
 
 using mozilla::Mutex;
 using mozilla::MutexAutoLock;
+using mozilla::SystemGroup;
+using mozilla::TaskCategory;
 using mozilla::TimeStamp;
 
 class CheckResponsivenessTask : public mozilla::Runnable,
                                 public nsITimerCallback {
 public:
   CheckResponsivenessTask()
     : mozilla::Runnable("CheckResponsivenessTask")
     , mLastTracerTime(TimeStamp::Now())
@@ -40,17 +44,19 @@ public:
   void DoFirstDispatchIfNeeded()
   {
     if (mHasEverBeenSuccessfullyDispatched) {
       return;
     }
 
     // Dispatching can fail during early startup, particularly when
     // MOZ_PROFILER_STARTUP is used.
-    nsresult rv = NS_DispatchToMainThread(this);
+    nsresult rv = SystemGroup::Dispatch("CheckResponsivenessTask",
+                                        TaskCategory::Other,
+                                        do_AddRef(this));
     if (NS_SUCCEEDED(rv)) {
       mHasEverBeenSuccessfullyDispatched = true;
     }
   }
 
   // Can only run on the main thread.
   NS_IMETHOD Run() override
   {
@@ -61,25 +67,28 @@ public:
     // This is raced on because we might pause the thread here
     // for profiling so if we tried to use a monitor to protect
     // mLastTracerTime we could deadlock. We're risking seeing
     // a partial write which will show up as an outlier in our
     // performance data.
     mLastTracerTime = TimeStamp::Now();
     if (!mTimer) {
       mTimer = do_CreateInstance("@mozilla.org/timer;1");
+      mTimer->SetTarget(SystemGroup::EventTargetFor(TaskCategory::Other));
     }
     mTimer->InitWithCallback(this, 16, nsITimer::TYPE_ONE_SHOT);
 
     return NS_OK;
   }
 
   NS_IMETHOD Notify(nsITimer* aTimer) final
   {
-    NS_DispatchToMainThread(this);
+    SystemGroup::Dispatch("CheckResponsivenessTask",
+                          TaskCategory::Other,
+                          do_AddRef(this));
     return NS_OK;
   }
 
   void Terminate() {
     MutexAutoLock mon(mMutex);
     mStop = true;
   }