Bug 1435091 - p4. Use profiler_thread_is_being_profiled() instead of profiler_is_active() around profiler_add_marker()s - r=mstange
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 19 Nov 2018 06:29:15 +0000
changeset 503861 02d02cae92cd78f17789bba914134955aa7b96c1
parent 503860 46d2f807824a82c2fb104122b98c67547d0bd328
child 503862 01b16c628645c783aacfa9dbd9fd370fadf96a8f
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 - p4. Use profiler_thread_is_being_profiled() instead of profiler_is_active() around profiler_add_marker()s - r=mstange (Unless there were other profiler actions, as I'm not sure yet whether it would be safe to skip them when the profiler is paused; another bug should investigate that.) Differential Revision: https://phabricator.services.mozilla.com/D11308
accessible/generic/Accessible.cpp
dom/base/nsDOMNavigationTiming.cpp
dom/indexedDB/ProfilerHelpers.h
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/ipc/CompositorBridgeParent.cpp
tools/profiler/gecko/ProfilerIOInterposeObserver.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/threads/nsThread.cpp
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -859,17 +859,17 @@ Accessible::XULElmName(DocAccessible* aD
 }
 
 nsresult
 Accessible::HandleAccEvent(AccEvent* aEvent)
 {
   NS_ENSURE_ARG_POINTER(aEvent);
 
 #ifdef MOZ_GECKO_PROFILER
-  if (profiler_is_active()) {
+  if (profiler_thread_is_being_profiled()) {
     nsAutoCString strEventType;
     GetAccService()->GetStringEventType(aEvent->GetEventType(), strEventType);
     nsAutoCString strMarker;
     strMarker.AppendLiteral("A11y Event - ");
     strMarker.Append(strEventType);
     profiler_add_marker(strMarker.get());
   }
 #endif
--- a/dom/base/nsDOMNavigationTiming.cpp
+++ b/dom/base/nsDOMNavigationTiming.cpp
@@ -382,17 +382,17 @@ nsDOMNavigationTiming::NotifyNonBlankPai
 
   if (!mNonBlankPaint.IsNull()) {
     return;
   }
 
   mNonBlankPaint = TimeStamp::Now();
 
 #ifdef MOZ_GECKO_PROFILER
-  if (profiler_is_active()) {
+  if (profiler_thread_is_being_profiled()) {
     TimeDuration elapsed = mNonBlankPaint - mNavigationStart;
     nsAutoCString spec;
     if (mLoadedURI) {
       mLoadedURI->GetSpec(spec);
     }
     nsPrintfCString marker("Non-blank paint after %dms for URL %s, %s",
                            int(elapsed.ToMilliseconds()), spec.get(),
                            mDocShellHasBeenActiveSinceNavigationStart ? "foreground tab" : "this tab was inactive some of the time between navigation start and first non-blank paint");
@@ -461,17 +461,17 @@ nsDOMNavigationTiming::NotifyDOMContentF
 
   if (!mDOMContentFlushed.IsNull()) {
     return;
   }
 
   mDOMContentFlushed = TimeStamp::Now();
 
 #ifdef MOZ_GECKO_PROFILER
-  if (profiler_is_active()) {
+  if (profiler_thread_is_being_profiled()) {
     TimeDuration elapsed = mDOMContentFlushed - mNavigationStart;
     nsAutoCString spec;
     if (mLoadedURI) {
       mLoadedURI->GetSpec(spec);
     }
     nsPrintfCString marker("DOMContentFlushed after %dms for URL %s, %s",
                            int(elapsed.ToMilliseconds()), spec.get(),
                            mDocShellHasBeenActiveSinceNavigationStart ? "foreground tab" : "this tab was inactive some of the time between navigation start and DOMContentFlushed");
--- a/dom/indexedDB/ProfilerHelpers.h
+++ b/dom/indexedDB/ProfilerHelpers.h
@@ -287,17 +287,17 @@ LoggingHelper(bool aUseProfiler, const c
 
   mozilla::LogModule* logModule = IndexedDatabaseManager::GetLoggingModule();
   MOZ_ASSERT(logModule);
 
   static const mozilla::LogLevel logLevel = LogLevel::Warning;
 
   if (MOZ_LOG_TEST(logModule, logLevel) ||
 #ifdef MOZ_GECKO_PROFILER
-      (aUseProfiler && profiler_is_active())
+      (aUseProfiler && profiler_thread_is_being_profiled())
 #else
       false
 #endif
      ) {
     nsAutoCString message;
 
     {
       va_list args;
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -81,17 +81,17 @@ DrawLayerInfo(const RenderTargetIntRect&
     aLayer->GetEffectiveTransform(), 16,
     maxWidth);
 }
 
 static void
 PrintUniformityInfo(Layer* aLayer)
 {
 #if defined(MOZ_GECKO_PROFILER)
-  if (!profiler_is_active()) {
+  if (!profiler_thread_is_being_profiled()) {
     return;
   }
 
   // Don't want to print a log for smaller layers
   if (aLayer->GetLocalVisibleRegion().GetBounds().Width() < 300 ||
       aLayer->GetLocalVisibleRegion().GetBounds().Height() < 300) {
     return;
   }
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -2071,19 +2071,21 @@ CompositorBridgeParent::GetAPZCTreeManag
   return apzctm.forget();
 }
 
 #if defined(MOZ_GECKO_PROFILER)
 static void
 InsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
 {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
-  profiler_add_marker(
-    "VsyncTimestamp",
-    MakeUnique<VsyncMarkerPayload>(aVsyncTimestamp));
+  if (profiler_thread_is_being_profiled()) {
+    profiler_add_marker(
+      "VsyncTimestamp",
+      MakeUnique<VsyncMarkerPayload>(aVsyncTimestamp));
+  }
 }
 #endif
 
 /*static */ void
 CompositorBridgeParent::PostInsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
 {
 #if defined(MOZ_GECKO_PROFILER)
   // Called in the vsync thread
--- a/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp
+++ b/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp
@@ -5,17 +5,17 @@
 #include "GeckoProfiler.h"
 #include "ProfilerIOInterposeObserver.h"
 #include "ProfilerMarkerPayload.h"
 
 using namespace mozilla;
 
 void ProfilerIOInterposeObserver::Observe(Observation& aObservation)
 {
-  if (!IsMainThread()) {
+  if (!IsMainThread() || !profiler_thread_is_being_profiled()) {
     return;
   }
 
   UniqueProfilerBacktrace stack = profiler_get_backtrace();
 
   nsString filename;
   aObservation.Filename(filename);
   profiler_add_marker(
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -834,17 +834,17 @@ CycleCollectedJSRuntime::GCCallback(JSCo
 CycleCollectedJSRuntime::GCSliceCallback(JSContext* aContext,
                                          JS::GCProgress aProgress,
                                          const JS::GCDescription& aDesc)
 {
   CycleCollectedJSRuntime* self = CycleCollectedJSRuntime::Get();
   MOZ_ASSERT(CycleCollectedJSContext::Get()->Context() == aContext);
 
 #ifdef MOZ_GECKO_PROFILER
-  if (profiler_is_active()) {
+  if (profiler_thread_is_being_profiled()) {
     if (aProgress == JS::GC_CYCLE_END) {
       profiler_add_marker(
         "GCMajor",
         MakeUnique<GCMajorMarkerPayload>(aDesc.startTime(aContext),
                                          aDesc.endTime(aContext),
                                          aDesc.summaryToJSON(aContext)));
     } else if (aProgress == JS::GC_SLICE_END) {
       profiler_add_marker(
@@ -935,17 +935,17 @@ CycleCollectedJSRuntime::GCNurseryCollec
     timelines->AddMarkerForAllObservedDocShells(abstractMarker);
   }
 
   if (aProgress == JS::GCNurseryProgress::GC_NURSERY_COLLECTION_START) {
     self->mLatestNurseryCollectionStart = TimeStamp::Now();
   }
 #ifdef MOZ_GECKO_PROFILER
   else if (aProgress == JS::GCNurseryProgress::GC_NURSERY_COLLECTION_END &&
-           profiler_is_active())
+           profiler_thread_is_being_profiled())
   {
     profiler_add_marker(
       "GCMinor",
       MakeUnique<GCMinorMarkerPayload>(self->mLatestNurseryCollectionStart,
                                        TimeStamp::Now(),
                                        JS::MinorGcToJSON(aContext)));
   }
 #endif
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -1250,17 +1250,17 @@ nsThread::ProcessNextEvent(bool aMayWait
         duration = now - mCurrentEventStart;
         if (duration.ToMilliseconds() > LONGTASK_BUSY_WINDOW_MS) {
           // Idle events (gc...) don't *really* count here
           if (priority != EventPriority::Idle) {
             mLastLongNonIdleTaskEnd = now;
           }
           mLastLongTaskEnd = now;
 #ifdef MOZ_GECKO_PROFILER
-          if (profiler_is_active()) {
+          if (profiler_thread_is_being_profiled()) {
               profiler_add_marker(
                 (priority != EventPriority::Idle) ? "LongTask" : "LongIdleTask",
                 MakeUnique<LongTaskMarkerPayload>(mCurrentEventStart, now));
           }
 #endif
         }
       }