Bug 1572235: Expose a method to remove markers leftover from previous runs of the profiler. r=gerald
authorWill Hawkins <whawkins@mozilla.com>
Fri, 09 Aug 2019 21:04:57 +0300
changeset 487439 c9c7f28c239366c6b6de7fb7bdd727f095e95f27
parent 487438 505047c3a1bdc160d7ac7d6e38318567e7a95f04
child 487440 be6d151634b6da1d25c47713ccff7445ee7acc0b
push id113877
push usernbeleuzu@mozilla.com
push dateMon, 12 Aug 2019 18:00:19 +0000
treeherdermozilla-inbound@c9c7f28c2393 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1572235
milestone70.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 1572235: Expose a method to remove markers leftover from previous runs of the profiler. r=gerald Differential Revision: https://phabricator.services.mozilla.com//D41275
tools/profiler/core/ProfilerMarker.h
tools/profiler/core/RegisteredThread.h
--- a/tools/profiler/core/ProfilerMarker.h
+++ b/tools/profiler/core/ProfilerMarker.h
@@ -128,16 +128,26 @@ class ProfilerSignalSafeLinkedList {
 
   ~ProfilerSignalSafeLinkedList() {
     if (mSignalLock) {
       // Some thread is modifying the list. We should only be released on that
       // thread.
       abort();
     }
 
+    reset();
+  }
+
+  // Reset the list of pending signals in this list.
+  // We assume that this is called at a time when it is
+  // guaranteed that no more than a single user (the caller)
+  // is accessing the list. In particular, it is only
+  // called from within the RacyRegisteredThread::ReinitializeOnResume
+  // method.
+  void reset() {
     while (mList.peek()) {
       delete mList.popHead();
     }
   }
 
   // Insert an item into the list. Must only be called from the owning thread.
   // Must not be called while the list from accessList() is being accessed.
   // In the profiler, we ensure that by interrupting the profiled thread
--- a/tools/profiler/core/RegisteredThread.h
+++ b/tools/profiler/core/RegisteredThread.h
@@ -54,16 +54,18 @@ class RacyRegisteredThread final {
     // Unless the profiled thread was in the middle of changing the list when
     // we interrupted it - in that case, accessList() will return null.
     return mPendingMarkers.accessList();
   }
 
   // This is called on every profiler restart. Put things that should happen at
   // that time here.
   void ReinitializeOnResume() {
+    mPendingMarkers.reset();
+
     // This is needed to cause an initial sample to be taken from sleeping
     // threads that had been observed prior to the profiler stopping and
     // restarting. Otherwise sleeping threads would not have any samples to
     // copy forward while sleeping.
     (void)mSleep.compareExchange(SLEEPING_OBSERVED, SLEEPING_NOT_OBSERVED);
   }
 
   // This returns true for the second and subsequent calls in each sleep cycle.