Bug 1435091 - p2. Don't record markers when current thread is not actively being profiled - r=mstange
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 19 Nov 2018 17:40:51 +0000
changeset 503859 a8d4a90124562be5adad841cd5fbbca834185f9a
parent 503858 9096b7d003cf01cfcc93372d81bf70b503818925
child 503860 46d2f807824a82c2fb104122b98c67547d0bd328
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1435091
milestone65.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 1435091 - p2. Don't record markers when current thread is not actively being profiled - r=mstange Differential Revision: https://phabricator.services.mozilla.com/D11306
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -3714,26 +3714,26 @@ ProfilerBacktraceDestructor::operator()(
 }
 
 static void
 racy_profiler_add_marker(const char* aMarkerName,
                          UniquePtr<ProfilerMarkerPayload> aPayload)
 {
   MOZ_RELEASE_ASSERT(CorePS::Exists());
 
-  // We don't assert that RacyFeatures::IsActiveWithoutPrivacy() is true here,
-  // because it's possible that the result has changed since we tested it in
-  // the caller.
+  // We don't assert that RacyFeatures::IsActiveWithoutPrivacy() or
+  // RacyRegisteredThread::IsBeingProfiled() is true here, because it's
+  // possible that the result has changed since we tested it in the caller.
   //
   // Because of this imprecision it's possible to miss a marker or record one
   // we shouldn't. Either way is not a big deal.
 
   RacyRegisteredThread* racyRegisteredThread =
     TLSRegisteredThread::RacyRegisteredThread();
-  if (!racyRegisteredThread) {
+  if (!racyRegisteredThread || !racyRegisteredThread->IsBeingProfiled()) {
     return;
   }
 
   TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull())
                        ? aPayload->GetStartTime()
                        : TimeStamp::Now();
   TimeDuration delta = origin - CorePS::ProcessStartTime();
   racyRegisteredThread->AddPendingMarker(aMarkerName, std::move(aPayload),