Bug 1431285 - Cap the number of style threads at six. r=emilio a=lizzard
authorBobby Holley <bobbyholley@gmail.com>
Tue, 03 Jul 2018 23:47:48 +0000
changeset 477892 ea180e6624d84b154178bd36daae496f93ad0d15
parent 477891 7938e31cdc975bb8239ead5ef24d2362f125e2b9
child 477893 9f52abcf637e7cc862cd12ddc4223055edd1dc66
push id9459
push userarchaeopteryx@coole-files.de
push dateWed, 11 Jul 2018 16:40:16 +0000
treeherdermozilla-beta@ae6366052310 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio, lizzard
bugs1431285
milestone62.0
Bug 1431285 - Cap the number of style threads at six. r=emilio a=lizzard MozReview-Commit-ID: 3qI1mIvDn8j Differential Revision: https://phabricator.services.mozilla.com/D1928
servo/components/style/gecko/global_style_data.rs
--- a/servo/components/style/gecko/global_style_data.rs
+++ b/servo/components/style/gecko/global_style_data.rs
@@ -60,17 +60,22 @@ fn thread_shutdown(_: usize) {
 
 lazy_static! {
     /// Global thread pool
     pub static ref STYLE_THREAD_POOL: StyleThreadPool = {
         let stylo_threads = env::var("STYLO_THREADS")
             .map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS value"));
         let mut num_threads = match stylo_threads {
             Ok(num) => num,
-            _ => cmp::max(num_cpus::get() * 3 / 4, 1),
+            // 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. The performance benefit of additional
+            // threads seems to level off at around six, so we cap it there on
+            // many-core machines (see bug 1431285 comment 14).
+            _ => cmp::min(cmp::max(num_cpus::get() * 3 / 4, 1), 6),
         };
 
         // If num_threads is one, there's no point in creating a thread pool, so
         // force it to zero.
         //
         // We allow developers to force a one-thread pool for testing via a
         // special environmental variable.
         if num_threads == 1 {