diff options
-rw-r--r-- | Cargo.lock | 62 | ||||
-rw-r--r-- | components/layout/parallel.rs | 6 | ||||
-rw-r--r-- | components/style/driver.rs | 7 | ||||
-rw-r--r-- | components/style/global_style_data.rs | 6 | ||||
-rw-r--r-- | components/style/parallel.rs | 8 | ||||
-rw-r--r-- | servo-tidy.toml | 1 | ||||
-rw-r--r-- | tests/unit/style/rule_tree/bench.rs | 12 |
7 files changed, 39 insertions, 63 deletions
diff --git a/Cargo.lock b/Cargo.lock index 9bd6cc52eb7..95950de8b93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -738,11 +738,11 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.2.0" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -756,20 +756,6 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-epoch" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ @@ -791,14 +777,6 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-utils" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2276,7 +2254,7 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2330,7 +2308,7 @@ dependencies = [ "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "profile_traits 0.0.1", "range 0.0.1", - "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "script_layout_interface 0.0.1", "script_traits 0.0.1", "selectors 0.21.0", @@ -2386,7 +2364,7 @@ dependencies = [ "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "profile_traits 0.0.1", "range 0.0.1", - "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "script 0.0.1", "script_layout_interface 0.0.1", "script_traits 0.0.1", @@ -3000,7 +2978,7 @@ dependencies = [ "openssl 0.10.11 (registry+https://github.com/rust-lang/crates.io-index)", "pixels 0.0.1", "profile_traits 0.0.1", - "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "servo_allocator 0.0.1", @@ -3661,21 +3639,23 @@ dependencies = [ [[package]] name = "rayon" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon-core" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4660,7 +4640,7 @@ dependencies = [ "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.21.0", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4706,7 +4686,7 @@ dependencies = [ "cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.21.0", "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "servo_arc 0.1.1", @@ -5418,7 +5398,7 @@ dependencies = [ "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "plane-split 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5778,12 +5758,10 @@ dependencies = [ "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e91d5240c6975ef33aeb5f148f35275c25eda8e8a5f95abe421978b05b8bf192" "checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" -"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" +"checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" -"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" "checksum crossbeam-epoch 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04c9e3102cc2d69cd681412141b390abd55a362afc1540965dad0ad4d34280b4" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" -"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" "checksum cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e06795910fc2f585a75bdc9690fbcc51e83519f07b6eb981db43944643c04933" @@ -6019,8 +5997,8 @@ dependencies = [ "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum raqote 0.4.1-alpha.0 (git+https://github.com/jrmuizel/raqote)" = "<none>" -"checksum rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "485541959c8ecc49865526fe6c4de9653dd6e60d829d6edf0be228167b60372d" -"checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" +"checksum rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b0186e22767d5b9738a05eab7c6ac90b15db17e5b5f9bd87976dd7d89a10a4" +"checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "29dbdfd4b9df8ab31dec47c6087b7b13cbf4a776f335e4de8efba8288dda075b" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index 0f98786498c..4ad10b3db11 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -116,7 +116,7 @@ fn bottom_up_flow(mut unsafe_flow: UnsafeFlow, assign_bsize_traversal: &AssignBS fn top_down_flow<'scope>( unsafe_flows: &[UnsafeFlow], pool: &'scope rayon::ThreadPool, - scope: &rayon::Scope<'scope>, + scope: &rayon::ScopeFifo<'scope>, assign_isize_traversal: &'scope AssignISizes, assign_bsize_traversal: &'scope AssignBSizes, ) { @@ -166,7 +166,7 @@ fn top_down_flow<'scope>( let first_chunk = chunks.next(); for chunk in chunks { let nodes = chunk.iter().cloned().collect::<FlowList>(); - scope.spawn(move |scope| { + scope.spawn_fifo(move |scope| { top_down_flow( &nodes, pool, @@ -212,7 +212,7 @@ pub fn reflow( let nodes = [UnsafeFlow(root)]; queue.install(move || { - rayon::scope(move |scope| { + rayon::scope_fifo(move |scope| { profile( time::ProfilerCategory::LayoutParallelWarmup, profiler_metadata, diff --git a/components/style/driver.rs b/components/style/driver.rs index 6b05bc85281..88ec933874e 100644 --- a/components/style/driver.rs +++ b/components/style/driver.rs @@ -133,7 +133,12 @@ pub fn traverse_dom<E, D>( let root_opaque = root.as_node().opaque(); let drain = discovered.drain(..); pool.install(|| { - rayon::scope(|scope| { + // Enable a breadth-first rayon traversal. This causes the work + // queue to be always FIFO, rather than FIFO for stealers and + // FILO for the owner (which is what rayon does by default). This + // ensures that we process all the elements at a given depth before + // proceeding to the next depth, which is important for style sharing. + rayon::scope_fifo(|scope| { profiler_label!(Style); parallel::traverse_nodes( drain, diff --git a/components/style/global_style_data.rs b/components/style/global_style_data.rs index e19cab37bfa..eff53078c9e 100644 --- a/components/style/global_style_data.rs +++ b/components/style/global_style_data.rs @@ -104,12 +104,6 @@ lazy_static! { } else { let workers = rayon::ThreadPoolBuilder::new() .num_threads(num_threads) - // Enable a breadth-first rayon traversal. This causes the work - // queue to be always FIFO, rather than FIFO for stealers and - // FILO for the owner (which is what rayon does by default). This - // ensures that we process all the elements at a given depth before - // proceeding to the next depth, which is important for style sharing. - .breadth_first() .thread_name(thread_name) .start_handler(thread_startup) .exit_handler(thread_shutdown) diff --git a/components/style/parallel.rs b/components/style/parallel.rs index 619be351579..d4aa0af6acf 100644 --- a/components/style/parallel.rs +++ b/components/style/parallel.rs @@ -104,7 +104,7 @@ fn top_down_dom<'a, 'scope, E, D>( nodes: &'a [SendNode<E::ConcreteNode>], root: OpaqueNode, mut traversal_data: PerLevelTraversalData, - scope: &'a rayon::Scope<'scope>, + scope: &'a rayon::ScopeFifo<'scope>, pool: &'scope rayon::ThreadPool, traversal: &'scope D, tls: &'scope ScopedTLS<'scope, ThreadLocalStyleContext<E>>, @@ -248,7 +248,7 @@ pub fn traverse_nodes<'a, 'scope, E, D, I>( recursion_ok: bool, root: OpaqueNode, traversal_data: PerLevelTraversalData, - scope: &'a rayon::Scope<'scope>, + scope: &'a rayon::ScopeFifo<'scope>, pool: &'scope rayon::ThreadPool, traversal: &'scope D, tls: &'scope ScopedTLS<'scope, ThreadLocalStyleContext<E>>, @@ -276,7 +276,7 @@ pub fn traverse_nodes<'a, 'scope, E, D, I>( if may_dispatch_tail { top_down_dom(&work, root, traversal_data, scope, pool, traversal, tls); } else { - scope.spawn(move |scope| { + scope.spawn_fifo(move |scope| { profiler_label!(Style); let work = work; top_down_dom(&work, root, traversal_data, scope, pool, traversal, tls); @@ -286,7 +286,7 @@ pub fn traverse_nodes<'a, 'scope, E, D, I>( for chunk in nodes.chunks(WORK_UNIT_MAX).into_iter() { let nodes: WorkUnit<E::ConcreteNode> = chunk.collect(); let traversal_data_copy = traversal_data.clone(); - scope.spawn(move |scope| { + scope.spawn_fifo(move |scope| { profiler_label!(Style); let n = nodes; top_down_dom(&*n, root, traversal_data_copy, scope, pool, traversal, tls) diff --git a/servo-tidy.toml b/servo-tidy.toml index 8d9783f1983..9d49ff467a5 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -33,7 +33,6 @@ rand = [ # Ignored packages with duplicated versions packages = [ "crossbeam-deque", - "crossbeam-epoch", "crossbeam-utils", "gl_generator", # https://github.com/servo/servo/pull/23288#issuecomment-494687746 "lock_api", diff --git a/tests/unit/style/rule_tree/bench.rs b/tests/unit/style/rule_tree/bench.rs index 1c561a1f215..a11174c6c35 100644 --- a/tests/unit/style/rule_tree/bench.rs +++ b/tests/unit/style/rule_tree/bench.rs @@ -187,13 +187,13 @@ fn bench_insertion_basic_parallel(b: &mut Bencher) { b.iter(|| { let _gc = AutoGCRuleTree::new(&r, &lock); - rayon::scope(|s| { + rayon::scope_fifo(|s| { for _ in 0..4 { - s.spawn(|s| { + s.spawn_fifo(|s| { for _ in 0..1000 { test::black_box(test_insertion(&r, rules_matched.clone())); } - s.spawn(|_| { + s.spawn_fifo(|_| { for _ in 0..100 { test::black_box(test_insertion(&r, rules_matched.clone())); } @@ -220,13 +220,13 @@ fn bench_expensive_insertion_parallel(b: &mut Bencher) { b.iter(|| { let _gc = AutoGCRuleTree::new(&r, &lock); - rayon::scope(|s| { + rayon::scope_fifo(|s| { for _ in 0..4 { - s.spawn(|s| { + s.spawn_fifo(|s| { for _ in 0..1000 { test::black_box(test_insertion_style_attribute(&r, &rules_matched, &lock)); } - s.spawn(|_| { + s.spawn_fifo(|_| { for _ in 0..100 { test::black_box(test_insertion_style_attribute( &r, |