зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1850573 - Override number of style threads on systems with heterogeneous CPUs. r=emilio
If there are 2 or more "big" CPUs then use the number of big CPUs as the number of threads. If there are fewer than 2 then use the number of big plus the number of "medium". Currently this only affects android, as hal::GetHeterogeneousCpuInfo is not implemented on other platforms. Differential Revision: https://phabricator.services.mozilla.com/D188480
This commit is contained in:
Родитель
5eee28f975
Коммит
71529c856c
|
@ -47,6 +47,7 @@
|
||||||
#include "mozilla/EffectCompositor.h"
|
#include "mozilla/EffectCompositor.h"
|
||||||
#include "mozilla/EffectSet.h"
|
#include "mozilla/EffectSet.h"
|
||||||
#include "mozilla/FontPropertyTypes.h"
|
#include "mozilla/FontPropertyTypes.h"
|
||||||
|
#include "mozilla/Hal.h"
|
||||||
#include "mozilla/Keyframe.h"
|
#include "mozilla/Keyframe.h"
|
||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
|
@ -1661,6 +1662,26 @@ bool Gecko_IsMainThread() { return NS_IsMainThread(); }
|
||||||
|
|
||||||
bool Gecko_IsDOMWorkerThread() { return !!GetCurrentThreadWorkerPrivate(); }
|
bool Gecko_IsDOMWorkerThread() { return !!GetCurrentThreadWorkerPrivate(); }
|
||||||
|
|
||||||
|
int32_t Gecko_GetNumStyleThreads() {
|
||||||
|
if (const auto& cpuInfo = hal::GetHeterogeneousCpuInfo()) {
|
||||||
|
size_t numBigCpus = cpuInfo->mBigCpus.Count();
|
||||||
|
// If CPUs are homogeneous we do not need to override stylo's
|
||||||
|
// default number of threads.
|
||||||
|
if (numBigCpus != cpuInfo->mTotalNumCpus) {
|
||||||
|
// From testing on a variety of devices it appears using only
|
||||||
|
// the number of big cores gives best performance when there are
|
||||||
|
// 2 or more big cores. If there are fewer than 2 big cores then
|
||||||
|
// additionally using the medium cores performs better.
|
||||||
|
if (numBigCpus >= 2) {
|
||||||
|
return static_cast<int32_t>(numBigCpus);
|
||||||
|
}
|
||||||
|
return static_cast<int32_t>(numBigCpus + cpuInfo->mMediumCpus.Count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
const nsAttrValue* Gecko_GetSVGAnimatedClass(const Element* aElement) {
|
const nsAttrValue* Gecko_GetSVGAnimatedClass(const Element* aElement) {
|
||||||
MOZ_ASSERT(aElement->IsSVGElement());
|
MOZ_ASSERT(aElement->IsSVGElement());
|
||||||
return static_cast<const SVGElement*>(aElement)->GetAnimatedClassName();
|
return static_cast<const SVGElement*>(aElement)->GetAnimatedClassName();
|
||||||
|
|
|
@ -609,6 +609,10 @@ bool Gecko_IsMainThread();
|
||||||
// Returns true if we're currently on a DOM worker thread.
|
// Returns true if we're currently on a DOM worker thread.
|
||||||
bool Gecko_IsDOMWorkerThread();
|
bool Gecko_IsDOMWorkerThread();
|
||||||
|
|
||||||
|
// Returns the preferred number of style threads to use, or -1 for no
|
||||||
|
// preference.
|
||||||
|
int32_t Gecko_GetNumStyleThreads();
|
||||||
|
|
||||||
// Media feature helpers.
|
// Media feature helpers.
|
||||||
//
|
//
|
||||||
// Defined in nsMediaFeatures.cpp.
|
// Defined in nsMediaFeatures.cpp.
|
||||||
|
|
|
@ -165,13 +165,22 @@ lazy_static! {
|
||||||
let threads_pref: i32 = stylo_threads_pref();
|
let threads_pref: i32 = stylo_threads_pref();
|
||||||
let num_threads = if threads_pref >= 0 {
|
let num_threads = if threads_pref >= 0 {
|
||||||
threads_pref as usize
|
threads_pref as usize
|
||||||
|
} else {
|
||||||
|
// Gecko may wish to override the default number of threads, for example on
|
||||||
|
// systems with heterogeneous CPUs.
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
let num_threads = unsafe { bindings::Gecko_GetNumStyleThreads() };
|
||||||
|
#[cfg(not(feature = "gecko"))]
|
||||||
|
let num_threads = -1;
|
||||||
|
|
||||||
|
if num_threads >= 0 {
|
||||||
|
num_threads as usize
|
||||||
} else {
|
} else {
|
||||||
use num_cpus;
|
use num_cpus;
|
||||||
// The default heuristic is num_virtual_cores * .75. This gives us three threads on a
|
// The default heuristic is num_virtual_cores * .75. This gives us three threads on a
|
||||||
// hyper-threaded dual core, and six threads on a hyper-threaded quad core.
|
// hyper-threaded dual core, and six threads on a hyper-threaded quad core.
|
||||||
let threads = cmp::max(num_cpus::get() * 3 / 4, 1);
|
cmp::max(num_cpus::get() * 3 / 4, 1)
|
||||||
// There's no point in creating a thread pool if there's one thread.
|
}
|
||||||
if threads == 1 { 0 } else { threads }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let num_threads = cmp::min(num_threads, STYLO_MAX_THREADS);
|
let num_threads = cmp::min(num_threads, STYLO_MAX_THREADS);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче