mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #16930 - bholley:limit_parallelism, r=emilio
Only use the parallel traversal when traversing from the root https://bugzilla.mozilla.org/show_bug.cgi?id=1365686 Let's get this in to see the impact on Talos. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16930) <!-- Reviewable:end -->
This commit is contained in:
commit
9d887a2375
2 changed files with 16 additions and 3 deletions
|
@ -57,12 +57,25 @@ lazy_static! {
|
|||
pub static ref GLOBAL_STYLE_DATA: GlobalStyleData = {
|
||||
let stylo_threads = env::var("STYLO_THREADS")
|
||||
.map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS value"));
|
||||
let num_threads = match stylo_threads {
|
||||
let mut num_threads = match stylo_threads {
|
||||
Ok(num) => num,
|
||||
_ => cmp::max(num_cpus::get() * 3 / 4, 1),
|
||||
};
|
||||
|
||||
let pool = if num_threads <= 1 {
|
||||
// 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 {
|
||||
let force_pool = env::var("FORCE_STYLO_THREAD_POOL")
|
||||
.ok().map_or(false, |s| s.parse::<usize>().expect("invalid FORCE_STYLO_THREAD_POOL value") == 1);
|
||||
if !force_pool {
|
||||
num_threads = 0;
|
||||
}
|
||||
}
|
||||
|
||||
let pool = if num_threads < 1 {
|
||||
None
|
||||
} else {
|
||||
let configuration = rayon::Configuration::new()
|
||||
|
|
|
@ -217,7 +217,7 @@ fn traverse_subtree(element: GeckoElement,
|
|||
};
|
||||
|
||||
let traversal = RecalcStyleOnly::new(shared_style_context, traversal_driver);
|
||||
if traversal_driver.is_parallel() {
|
||||
if traversal_driver.is_parallel() && element.is_root() {
|
||||
parallel::traverse_dom(&traversal, element, token,
|
||||
global_style_data.style_thread_pool.as_ref().unwrap());
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue