Bug 1473732 - Default OMTP workers to number of logical cores. r?rhunt draft
authorJan Beich <jbeich@FreeBSD.org>
Sat, 30 Jun 2018 22:41:59 +0000
changeset 814655 239bf26674bf80e83bf06f1aee26eb8bcf0db26d
parent 814584 e8b7331398910233e3adaaed01cad6b75bb562a2
push id115304
push userbmo:jbeich@FreeBSD.org
push dateThu, 05 Jul 2018 21:42:10 +0000
reviewersrhunt
bugs1473732
milestone63.0a1
Bug 1473732 - Default OMTP workers to number of logical cores. r?rhunt system-info is a stub on Tier3 platforms and for OS scheduling logical vs. physical doesn't matter unless CPU affinity was requested. MozReview-Commit-ID: 1Yh8rJL2JcN
gfx/layers/PaintThread.cpp
--- a/gfx/layers/PaintThread.cpp
+++ b/gfx/layers/PaintThread.cpp
@@ -16,17 +16,17 @@
 #include "mozilla/layers/ShadowLayers.h"
 #include "mozilla/layers/SyncObject.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/SharedThreadPool.h"
 #include "mozilla/SyncRunnable.h"
 #include "nsIPropertyBag2.h"
 #include "nsServiceManagerUtils.h"
-#include "nsSystemInfo.h"
+#include "prsystem.h"
 
 // Uncomment the following line to dispatch sync runnables when
 // painting so that rasterization happens synchronously from
 // the perspective of the main thread
 // #define OMTP_FORCE_SYNC
 
 namespace mozilla {
 namespace layers {
@@ -117,25 +117,17 @@ PaintThread::Release()
 void
 PaintThread::AddRef()
 {
 }
 
 /* static */ int32_t
 PaintThread::CalculatePaintWorkerCount()
 {
-  int32_t cpuCores = 1;
-  nsCOMPtr<nsIPropertyBag2> systemInfo = do_GetService(NS_SYSTEMINFO_CONTRACTID);
-  if (systemInfo) {
-    nsresult rv = systemInfo->GetPropertyAsInt32(NS_LITERAL_STRING("cpucores"), &cpuCores);
-    if (NS_FAILED(rv)) {
-      cpuCores = 1;
-    }
-  }
-
+  int32_t cpuCores = PR_GetNumberOfProcessors();
   int32_t workerCount = gfxPrefs::LayersOMTPPaintWorkers();
 
   // If not manually specified, default to (cpuCores * 3) / 4, and clamp
   // between 1 and 4. If a user wants more, they can manually specify it
   if (workerCount < 1) {
     workerCount = std::min(std::max((cpuCores * 3) / 4, 1), 4);
   }