Bug 1559000 - Enable/disable mozglue's AutoProfilerLabel when Gecko Profiler starts/stops - r=mstange
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 04 Jul 2019 04:38:54 +0000
changeset 481215 cb011f546027671fffd2305ad6cadc76fa140828
parent 481214 c9da4cd2c6f56a3b6034c41fb208e583ba0cbcd3
child 481216 c52f0346e63018272764bcfd879c8390c40a12ac
push id36236
push userrmaries@mozilla.com
push dateThu, 04 Jul 2019 21:41:54 +0000
treeherdermozilla-central@9340f815a2d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1559000
milestone69.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 1559000 - Enable/disable mozglue's AutoProfilerLabel when Gecko Profiler starts/stops - r=mstange Instead of setting entry&exit function when Gecko Profiler is initialized, we now set them when profiling actually starts, and reset them when profiling stops. There may be edge cases (missing or unneeded labels at the very start or end of a session) are not an issue. Differential Revision: https://phabricator.services.mozilla.com/D34808
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -2924,19 +2924,16 @@ void profiler_init(void* aStackTop) {
 #endif
 
 #if defined(GP_OS_android)
     if (jni::IsAvailable()) {
       GeckoJavaSampler::Init();
     }
 #endif
 
-    // Setup support for pushing/popping labels in mozglue.
-    RegisterProfilerLabelEnterExit(MozGlueLabelEnter, MozGlueLabelExit);
-
     // (Linux-only) We could create CorePS::mLul and read unwind info into it
     // at this point. That would match the lifetime implied by destruction of
     // it in profiler_shutdown() just below. However, that gives a big delay on
     // startup, even if no profiling is actually to be done. So, instead, it is
     // created on demand at the first call to PlatformStart().
 
     const char* startupEnv = getenv("MOZ_PROFILER_STARTUP");
     if (!startupEnv || startupEnv[0] == '\0') {
@@ -3472,16 +3469,19 @@ static void locked_profiler_start(PSLock
       }
       registeredThread->RacyRegisteredThread().ReinitializeOnResume();
       if (registeredThread->GetJSContext()) {
         profiledThreadData->NotifyReceivedJSContext(0);
       }
     }
   }
 
+  // Setup support for pushing/popping labels in mozglue.
+  RegisterProfilerLabelEnterExit(MozGlueLabelEnter, MozGlueLabelExit);
+
 #ifdef MOZ_TASK_TRACER
   if (ActivePS::FeatureTaskTracer(aLock)) {
     tasktracer::StartLogging();
   }
 #endif
 
 #if defined(GP_OS_android)
   if (ActivePS::FeatureJava(aLock)) {
@@ -3612,16 +3612,19 @@ static MOZ_MUST_USE SamplerThread* locke
 #endif
 
 #ifdef MOZ_TASK_TRACER
   if (ActivePS::FeatureTaskTracer(aLock)) {
     tasktracer::StopLogging();
   }
 #endif
 
+  // Remove support for pushing/popping labels in mozglue.
+  RegisterProfilerLabelEnterExit(nullptr, nullptr);
+
   // Stop sampling live threads.
   int tid = profiler_current_thread_id();
   const Vector<LiveProfiledThreadData>& liveProfiledThreads =
       ActivePS::LiveProfiledThreads(aLock);
   for (auto& thread : liveProfiledThreads) {
     RegisteredThread* registeredThread = thread.mRegisteredThread;
     registeredThread->RacyRegisteredThread().SetIsBeingProfiled(false);
     if (ActivePS::FeatureJS(aLock)) {