Bug 1195767 - part 5 - use signaling instead of broadcast when work items are placed in nsEventQueue; r=gerald, a=sledru
authorNathan Froyd <froydnj@mozilla.com>
Thu, 03 Sep 2015 16:38:18 -0400
changeset 289248 a7bb121ef972f05ab331dab7446410aac25f6165
parent 289247 27de5abd6cff7fc9a6b60ed2cef67872681f48d8
child 289249 7239a71b423fd9e18ed6b6f2bdfc254b23e20a17
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, sledru
bugs1195767
milestone42.0a2
Bug 1195767 - part 5 - use signaling instead of broadcast when work items are placed in nsEventQueue; r=gerald, a=sledru There's no reason to wake up all the threads in a thread pool when one item gets placed in the queue. Waking up one will serve the same purpose and is significantly more efficient for thread pools with large numbers of threads.
xpcom/threads/nsEventQueue.cpp
--- a/xpcom/threads/nsEventQueue.cpp
+++ b/xpcom/threads/nsEventQueue.cpp
@@ -127,17 +127,17 @@ nsEventQueueBase<MonitorType>::PutEvent(
     mOffsetTail = 0;
   }
 
   nsIRunnable*& queueLocation = mTail->mEvents[mOffsetTail];
   MOZ_ASSERT(!queueLocation);
   queueLocation = aRunnable.take();
   ++mOffsetTail;
   LOG(("EVENTQ(%p): notify\n", this));
-  aProofOfLock.NotifyAll();
+  aProofOfLock.Notify();
 }
 
 template void nsEventQueueBase<Monitor>::PutEvent(already_AddRefed<nsIRunnable>&& aRunnable,
                                                   MonitorAutoLock& aProofOfLock);
 template void nsEventQueueBase<ReentrantMonitor>::PutEvent(already_AddRefed<nsIRunnable>&& aRunnable,
                                                            ReentrantMonitorAutoEnter& aProofOfLock);
 
 void