Bug 1322435. Limit the number of image decoding threads we use in the parent process. r=aosmond
authorTimothy Nikkel <tnikkel@gmail.com>
Thu, 08 Dec 2016 18:20:13 -0600
changeset 325462 d8f60ae71774924b84fb6347057c7fd45394ed03
parent 325461 5cebfb1902a202b578c35d65575096348cdedf2b
child 325463 853a0dfc4d5f5d0a4edb51e9b6356b547556ecc5
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersaosmond
bugs1322435
milestone53.0a1
Bug 1322435. Limit the number of image decoding threads we use in the parent process. r=aosmond There aren't as many images in chrome to decode, and they aren't as big, so we don't need as many threads.
image/DecodePool.cpp
--- a/image/DecodePool.cpp
+++ b/image/DecodePool.cpp
@@ -11,16 +11,17 @@
 #include "mozilla/Monitor.h"
 #include "nsCOMPtr.h"
 #include "nsIObserverService.h"
 #include "nsIThreadPool.h"
 #include "nsThreadManager.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOMCIDInternal.h"
 #include "prsystem.h"
+#include "nsIXULRuntime.h"
 
 #include "gfxPrefs.h"
 
 #include "Decoder.h"
 #include "IDecodingTask.h"
 #include "RasterImage.h"
 
 using std::max;
@@ -256,16 +257,21 @@ DecodePool::DecodePool()
       limit = numCores - 1;
     }
   } else {
     limit = static_cast<uint32_t>(prefLimit);
   }
   if (limit > 32) {
     limit = 32;
   }
+  // The parent process where there are content processes doesn't need as many
+  // threads for decoding images.
+  if (limit > 4 && XRE_IsParentProcess() && BrowserTabsRemoteAutostart()) {
+    limit = 4;
+  }
 
   // Initialize the thread pool.
   for (uint32_t i = 0 ; i < limit ; ++i) {
     nsCOMPtr<nsIRunnable> worker = new DecodePoolWorker(mImpl);
     nsCOMPtr<nsIThread> thread;
     nsresult rv = NS_NewThread(getter_AddRefs(thread), worker);
     MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv) && thread,
                        "Should successfully create image decoding threads");