Bug 951713 - CacheIOThread causes activity spikes during idle, r=michal
authorHonza Bambas <honzab.moz@firemni.cz>
Thu, 19 Dec 2013 01:39:16 +0100
changeset 161192 86eb809847a34eb495b806bdfeec0bad3abaedef
parent 161190 f12f6b1c64cb7d6b121a6a8c85ba68cb8fe520fd
child 161193 f6588099c40bca005474bf3f198fdd7ce3b98e68
push id25870
push usercbook@mozilla.com
push dateThu, 19 Dec 2013 09:28:59 +0000
treeherdermozilla-central@35c6a9cd23b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs951713
milestone29.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 951713 - CacheIOThread causes activity spikes during idle, r=michal
netwerk/cache2/CacheIOThread.cpp
--- a/netwerk/cache2/CacheIOThread.cpp
+++ b/netwerk/cache2/CacheIOThread.cpp
@@ -117,18 +117,16 @@ void CacheIOThread::ThreadFunc()
     mXPCOMThread = NS_GetCurrentThread();
 
     threadInternal = do_QueryInterface(mXPCOMThread);
     if (threadInternal)
       threadInternal->SetObserver(this);
 
     lock.NotifyAll();
 
-    static PRIntervalTime const waitTime = PR_MillisecondsToInterval(5000);
-
     do {
 loopStart:
       // Reset the lowest level now, so that we can detect a new event on
       // a lower level (i.e. higher priority) has been scheduled while
       // executing any previously scheduled event.
       mLowestLevelWaiting = LAST_LEVEL;
 
       // Process xpcom events first
@@ -155,24 +153,27 @@ loopStart:
 
         LoopOneLevel(level);
 
         // Go to the first (lowest) level again
         goto loopStart;
       }
 
       if (EventsPending())
-        goto loopStart;
+        continue;
 
-      lock.Wait(waitTime);
+      if (mShutdown)
+        break;
+
+      lock.Wait(PR_INTERVAL_NO_TIMEOUT);
 
       if (EventsPending())
-        goto loopStart;
+        continue;
 
-    } while (!mShutdown);
+    } while (true);
 
     MOZ_ASSERT(!EventsPending());
   } // lock
 
   if (threadInternal)
     threadInternal->SetObserver(nullptr);
 }