Bug 1162242 - Part 2: Remove DEBUG_TIMERS. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Thu, 07 May 2015 09:43:36 -0700
changeset 274201 917d62c82b1d94f1019f76ca21ef03106aedd693
parent 274200 3c8a77e2a83faceccbf691f3d2d7d1840c10f989
child 274202 d7ae6f7c3e20bcc6ec15de62103c5d7a9a540b3f
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1162242
milestone40.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 1162242 - Part 2: Remove DEBUG_TIMERS. r=froydnj Now that PR_LOGGING is always defined DEBUG_TIMERS will always be set. It can now be removed.
xpcom/threads/TimerThread.cpp
xpcom/threads/nsTimerImpl.cpp
xpcom/threads/nsTimerImpl.h
--- a/xpcom/threads/TimerThread.cpp
+++ b/xpcom/threads/TimerThread.cpp
@@ -255,23 +255,21 @@ TimerThread::Run()
           // from mTimers have gone away (the last non-mTimers[i]-ref's Release
           // must be racing with us, blocked in gThread->RemoveTimer waiting
           // for TimerThread::mMonitor, under nsTimerImpl::Release.
 
           nsRefPtr<nsTimerImpl> timerRef(timer);
           RemoveTimerInternal(timer);
           timer = nullptr;
 
-#ifdef DEBUG_TIMERS
           if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
             PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
                    ("Timer thread woke up %fms from when it was supposed to\n",
                     fabs((now - timerRef->mTimeout).ToMilliseconds())));
           }
-#endif
 
           {
             // We release mMonitor around the Fire call to avoid deadlock.
             MonitorAutoUnlock unlock(mMonitor);
 
             // We are going to let the call to PostTimerEvent here handle the
             // release of the timer so that we don't end up releasing the timer
             // on the TimerThread instead of on the thread it targets.
@@ -341,26 +339,24 @@ TimerThread::Run()
         }
         waitFor = PR_MicrosecondsToInterval(
           static_cast<uint32_t>(microseconds)); // Floor is accurate enough.
         if (waitFor == 0) {
           waitFor = 1;  // round up, wait the minimum time we can wait
         }
       }
 
-#ifdef DEBUG_TIMERS
       if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
         if (waitFor == PR_INTERVAL_NO_TIMEOUT)
           PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
                  ("waiting for PR_INTERVAL_NO_TIMEOUT\n"));
         else
           PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
                  ("waiting for %u\n", PR_IntervalToMilliseconds(waitFor)));
       }
-#endif
     }
 
     mWaiting = true;
     mNotified = false;
     mMonitor.Wait(waitFor);
     if (mNotified) {
       forceRunNextTimer = false;
     }
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -19,18 +19,16 @@
 
 using mozilla::Atomic;
 using mozilla::TimeDuration;
 using mozilla::TimeStamp;
 
 static Atomic<int32_t>  gGenerator;
 static TimerThread*     gThread = nullptr;
 
-#ifdef DEBUG_TIMERS
-
 PRLogModuleInfo*
 GetTimerLog()
 {
   static PRLogModuleInfo* sLog;
   if (!sLog) {
     sLog = PR_NewLogModule("nsTimerImpl");
   }
   return sLog;
@@ -56,17 +54,16 @@ myNS_MeanAndStdDev(double n, double sumO
       var = temp / (n * (n - 1));
     }
     // for some reason, Windows says sqrt(0.0) is "-1.#J" (?!) so do this:
     stdDev = var != 0.0 ? sqrt(var) : 0.0;
   }
   *meanResult = mean;
   *stdDevResult = stdDev;
 }
-#endif
 
 namespace {
 
 // TimerEventAllocator is a thread-safe allocator used only for nsTimerEvents.
 // It's needed to avoid contention over the default allocator lock when
 // firing timer events (see bug 733277).  The thread-safety is required because
 // nsTimerEvent objects are allocated on the timer thread, and freed on another
 // thread.  Because TimerEventAllocator has its own lock, contention over that
@@ -122,19 +119,17 @@ public:
     MOZ_COUNT_CTOR(nsTimerEvent);
 
     MOZ_ASSERT(gThread->IsOnTimerThread(),
                "nsTimer must always be allocated on the timer thread");
 
     sAllocatorUsers++;
   }
 
-#ifdef DEBUG_TIMERS
   TimeStamp mInitTime;
-#endif
 
   static void Init();
   static void Shutdown();
   static void DeleteAllocatorIfNeeded();
 
   static void* operator new(size_t aSize) CPP_THROW_NEW
   {
     return sAllocator->Alloc(aSize);
@@ -313,28 +308,26 @@ nsTimerImpl::Startup()
   }
 
   return rv;
 }
 
 void
 nsTimerImpl::Shutdown()
 {
-#ifdef DEBUG_TIMERS
   if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
     double mean = 0, stddev = 0;
     myNS_MeanAndStdDev(sDeltaNum, sDeltaSum, sDeltaSumSquared, &mean, &stddev);
 
     PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
            ("sDeltaNum = %f, sDeltaSum = %f, sDeltaSumSquared = %f\n",
             sDeltaNum, sDeltaSum, sDeltaSumSquared));
     PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
            ("mean: %fms, stddev: %fms\n", mean, stddev));
   }
-#endif
 
   if (!gThread) {
     return;
   }
 
   gThread->Shutdown();
   NS_RELEASE(gThread);
 
@@ -570,17 +563,16 @@ nsTimerImpl::Fire()
 
 #ifdef MOZ_TASK_TRACER
   // mTracedTask is an instance of FakeTracedTask created by
   // DispatchTracedTask(). AutoRunFakeTracedTask logs the begin/end time of the
   // timer/FakeTracedTask instance in ctor/dtor.
   mozilla::tasktracer::AutoRunFakeTracedTask runTracedTask(mTracedTask);
 #endif
 
-#ifdef DEBUG_TIMERS
   TimeStamp now = TimeStamp::Now();
   if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
     TimeDuration   a = now - mStart; // actual delay in intervals
     TimeDuration   b = TimeDuration::FromMilliseconds(mDelay); // expected delay in intervals
     TimeDuration   delta = (a > b) ? a - b : b - a;
     uint32_t       d = delta.ToMilliseconds(); // delta in ms
     sDeltaSum += d;
     sDeltaSumSquared += double(d) * double(d);
@@ -595,17 +587,16 @@ nsTimerImpl::Fire()
            ("[this=%p] (mType is %d)       -------\n", this, mType));
     PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
            ("[this=%p]     delta           %4dms\n",
             this, (a > b) ? (int32_t)d : -(int32_t)d));
 
     mStart = mStart2;
     mStart2 = TimeStamp();
   }
-#endif
 
   TimeStamp timeout = mTimeout;
   if (IsRepeatingPrecisely()) {
     // Precise repeating timers advance mTimeout by mDelay without fail before
     // calling Fire().
     timeout -= TimeDuration::FromMilliseconds(mDelay);
   }
 
@@ -654,23 +645,21 @@ nsTimerImpl::Fire()
     } else if (callbackType == CallbackType::Observer) {
       NS_RELEASE(callback.o);
     }
   }
 
   mFiring = false;
   mTimerCallbackWhileFiring = nullptr;
 
-#ifdef DEBUG_TIMERS
   if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
     PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
            ("[this=%p] Took %fms to fire timer callback\n",
             this, (TimeStamp::Now() - now).ToMilliseconds()));
   }
-#endif
 
   // Reschedule repeating timers, except REPEATING_PRECISE which already did
   // that in PostTimerEvent, but make sure that we aren't armed already (which
   // can happen if the callback reinitialized the timer).
   if (IsRepeating() && mType != TYPE_REPEATING_PRECISE && !mArmed) {
     if (mType == TYPE_REPEATING_SLACK) {
       SetDelayInternal(mDelay);  // force mTimeout to be recomputed.  For
     }
@@ -706,24 +695,22 @@ nsTimerEvent::DeleteAllocatorIfNeeded()
 
 NS_IMETHODIMP
 nsTimerEvent::Run()
 {
   if (mGeneration != mTimer->GetGeneration()) {
     return NS_OK;
   }
 
-#ifdef DEBUG_TIMERS
   if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
     TimeStamp now = TimeStamp::Now();
     PR_LOG(GetTimerLog(), PR_LOG_DEBUG,
            ("[this=%p] time between PostTimerEvent() and Fire(): %fms\n",
             this, (now - mInitTime).ToMilliseconds()));
   }
-#endif
 
   mTimer->Fire();
   // Since nsTimerImpl is not thread-safe, we should release |mTimer|
   // here in the target thread to avoid race condition. Otherwise,
   // ~nsTimerEvent() which calls nsTimerImpl::Release() could run in the
   // timer thread and result in race condition.
   mTimer = nullptr;
 
@@ -749,21 +736,19 @@ nsTimerImpl::PostTimerEvent(already_AddR
 
   // Note: We override operator new for this class, and the override is
   // fallible!
   nsRefPtr<nsTimerEvent> event = new nsTimerEvent;
   if (!event) {
     return timer.forget();
   }
 
-#ifdef DEBUG_TIMERS
   if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
     event->mInitTime = TimeStamp::Now();
   }
-#endif
 
   // If this is a repeating precise timer, we need to calculate the time for
   // the next timer to fire before we make the callback.
   if (timer->IsRepeatingPrecisely()) {
     timer->SetDelayInternal(timer->mDelay);
 
     // But only re-arm REPEATING_PRECISE timers.
     if (gThread && timer->mType == TYPE_REPEATING_PRECISE) {
@@ -798,24 +783,22 @@ nsTimerImpl::SetDelayInternal(uint32_t a
 
   TimeStamp now = TimeStamp::Now();
   if (mTimeout.IsNull() || mType != TYPE_REPEATING_PRECISE) {
     mTimeout = now;
   }
 
   mTimeout += delayInterval;
 
-#ifdef DEBUG_TIMERS
   if (PR_LOG_TEST(GetTimerLog(), PR_LOG_DEBUG)) {
     if (mStart.IsNull()) {
       mStart = now;
     } else {
       mStart2 = now;
     }
   }
-#endif
 }
 
 size_t
 nsTimerImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
 {
   return aMallocSizeOf(this);
 }
--- a/xpcom/threads/nsTimerImpl.h
+++ b/xpcom/threads/nsTimerImpl.h
@@ -17,17 +17,16 @@
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Attributes.h"
 
 #ifdef MOZ_TASK_TRACER
 #include "TracedTaskCommon.h"
 #endif
 
 extern PRLogModuleInfo* GetTimerLog();
-#define DEBUG_TIMERS 1
 
 #define NS_TIMER_CID \
 { /* 5ff24248-1dd2-11b2-8427-fbab44f29bc8 */         \
      0x5ff24248,                                     \
      0x1dd2,                                         \
      0x11b2,                                         \
     {0x84, 0x27, 0xfb, 0xab, 0x44, 0xf2, 0x9b, 0xc8} \
 }
@@ -148,18 +147,15 @@ private:
 
   uint32_t              mDelay;
   TimeStamp             mTimeout;
 
 #ifdef MOZ_TASK_TRACER
   nsRefPtr<mozilla::tasktracer::FakeTracedTask> mTracedTask;
 #endif
 
-#ifdef DEBUG_TIMERS
   TimeStamp             mStart, mStart2;
   static double         sDeltaSum;
   static double         sDeltaSumSquared;
   static double         sDeltaNum;
-#endif
-
 };
 
 #endif /* nsTimerImpl_h___ */