Bug 1339327 (part 8) - Move the LUL printing check out of SignalSender()'s inner loop. r=jseward.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 15 Feb 2017 14:26:23 +1100
changeset 342950 e538c3740be131f78a98129221f16d4dacb29906
parent 342949 542fffc2c125254f39a8457abfb69671269c6dd1
child 342951 5b04e3138909162549eb6c7933365ba1e4fb81b5
push id31366
push usercbook@mozilla.com
push dateWed, 15 Feb 2017 11:25:19 +0000
treeherdermozilla-central@c0807d6938c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjseward
bugs1339327
milestone54.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 1339327 (part 8) - Move the LUL printing check out of SignalSender()'s inner loop. r=jseward. Instead of calling MaybeShowStats() every 16th time around the inner loop we now check every time around the outer loop. Because there are typically 20--50 threads running at once, this results in a slightly lower freqency of printing, but that seems fine because this is debug-only code.
tools/profiler/core/platform-linux.cc
--- a/tools/profiler/core/platform-linux.cc
+++ b/tools/profiler/core/platform-linux.cc
@@ -260,18 +260,16 @@ SigprofSender(void* aArg)
   // This function runs on its own thread.
 
   // Taken from platform_thread_posix.cc
   prctl(PR_SET_NAME, "SamplerThread", 0, 0, 0);
 
   int vm_tgid_ = getpid();
   DebugOnly<int> my_tid = gettid();
 
-  unsigned int nSignalsSent = 0;
-
   TimeDuration lastSleepOverhead = 0;
   TimeStamp sampleStart = TimeStamp::Now();
   while (gIsActive) {
     gBuffer->deleteExpiredStoredMarkers();
 
     if (!gIsPaused) {
       StaticMutexAutoLock lock(gRegisteredThreadsMutex);
 
@@ -319,28 +317,25 @@ SigprofSender(void* aArg)
 #else
           continue;
 #endif
         }
 
         // Wait for the signal handler to run before moving on to the next one
         sem_wait(&gSignalHandlingDone);
         isFirstProfiledThread = false;
-
-        // The LUL unwind object accumulates frame statistics.
-        // Periodically we should poke it to give it a chance to print
-        // those statistics.  This involves doing I/O (fprintf,
-        // __android_log_print, etc) and so can't safely be done from
-        // the unwinder threads, which is why it is done here.
-        if ((++nSignalsSent & 0xF) == 0) {
-#          if defined(USE_LUL_STACKWALK)
-           gLUL->MaybeShowStats();
-#          endif
-        }
       }
+#if defined(USE_LUL_STACKWALK)
+      // The LUL unwind object accumulates frame statistics. Periodically we
+      // should poke it to give it a chance to print those statistics. This
+      // involves doing I/O (fprintf, __android_log_print, etc.) and so can't
+      // safely be done from the unwinder threads, which is why it is done
+      // here.
+      gLUL->MaybeShowStats();
+#endif
     }
 
     // This off-main-thread use of gInterval is safe due to implicit
     // synchronization -- this function cannot run at the same time as
     // profiler_{start,stop}(), where gInterval is set.
     TimeStamp targetSleepEndTime =
       sampleStart + TimeDuration::FromMicroseconds(gInterval * 1000);
     TimeStamp beforeSleep = TimeStamp::Now();