aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-02-23 10:15:41 -0800
committerGitHub <noreply@github.com>2017-02-23 10:15:41 -0800
commit56a99577b31a942e340624f97377980b0e612088 (patch)
tree388a38b9ed2280c1ce9e5aad147315a5cfb586d4 /components
parenta780f6f28cf5d0f4faa7ad84822692d9bab1d031 (diff)
parent4a1dd9fa57da60120c35d4a21a755f72c5cc671c (diff)
downloadservo-56a99577b31a942e340624f97377980b0e612088.tar.gz
servo-56a99577b31a942e340624f97377980b0e612088.zip
Auto merge of #15535 - froydnj:global-style-thread-pool, r=bholley
geckolib: use a global thread pool for styling By having a single thread pool, rather than one per document, we use less memory. This addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1324250. This may be obvious to an experienced Rust programmer, but I went with raw pointers because trying to use `Option` global variables resulted in complaints about turning on feature flags in nightly Rust. Since this is for stylo, nightly features are not appropriate here. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/15535) <!-- Reviewable:end -->
Diffstat (limited to 'components')
-rw-r--r--components/style/Cargo.toml6
-rw-r--r--components/style/gecko/data.rs35
-rw-r--r--components/style/lib.rs1
3 files changed, 1 insertions, 41 deletions
diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml
index 563c7ed0967..7576ec4b7ea 100644
--- a/components/style/Cargo.toml
+++ b/components/style/Cargo.toml
@@ -13,7 +13,7 @@ path = "lib.rs"
doctest = false
[features]
-gecko = ["nsstring_vendor", "num_cpus", "rayon/unstable"]
+gecko = ["nsstring_vendor", "rayon/unstable"]
use_bindgen = ["bindgen", "regex"]
servo = ["serde/unstable", "serde", "serde_derive", "heapsize_derive",
"style_traits/servo", "servo_atoms", "html5ever-atoms",
@@ -57,10 +57,6 @@ servo_url = {path = "../url"}
time = "0.1"
unicode-segmentation = "1.0"
-[dependencies.num_cpus]
-optional = true
-version = "1.0"
-
[target.'cfg(windows)'.dependencies]
kernel32-sys = "0.2"
diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs
index 4ecfe1df520..89c18fa6a06 100644
--- a/components/style/gecko/data.rs
+++ b/components/style/gecko/data.rs
@@ -11,13 +11,9 @@ use gecko_bindings::bindings::RawServoStyleSet;
use gecko_bindings::structs::RawGeckoPresContextOwned;
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use media_queries::Device;
-use num_cpus;
use parking_lot::RwLock;
use properties::ComputedValues;
-use rayon;
-use std::cmp;
use std::collections::HashMap;
-use std::env;
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
use stylesheets::Stylesheet;
@@ -48,29 +44,12 @@ pub struct PerDocumentStyleDataImpl {
/// Unused. Will go away when we actually implement transitions and
/// animations properly.
pub expired_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
-
- /// The worker thread pool.
- /// FIXME(bholley): This shouldn't be per-document.
- pub work_queue: Option<rayon::ThreadPool>,
-
- /// The number of threads of the work queue.
- pub num_threads: usize,
}
/// The data itself is an `AtomicRefCell`, which guarantees the proper semantics
/// and unexpected races while trying to mutate it.
pub struct PerDocumentStyleData(AtomicRefCell<PerDocumentStyleDataImpl>);
-lazy_static! {
- /// The number of layout threads, computed statically.
- pub static ref NUM_THREADS: usize = {
- match env::var("STYLO_THREADS").map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS")) {
- Ok(num) => num,
- _ => cmp::max(num_cpus::get() * 3 / 4, 1),
- }
- };
-}
-
impl PerDocumentStyleData {
/// Create a dummy `PerDocumentStyleData`.
pub fn new(pres_context: RawGeckoPresContextOwned) -> Self {
@@ -86,14 +65,6 @@ impl PerDocumentStyleData {
new_animations_receiver: new_anims_receiver,
running_animations: Arc::new(RwLock::new(HashMap::new())),
expired_animations: Arc::new(RwLock::new(HashMap::new())),
- work_queue: if *NUM_THREADS <= 1 {
- None
- } else {
- let configuration =
- rayon::Configuration::new().set_num_threads(*NUM_THREADS);
- rayon::ThreadPool::new(configuration).ok()
- },
- num_threads: *NUM_THREADS,
}))
}
@@ -141,9 +112,3 @@ unsafe impl HasFFI for PerDocumentStyleData {
}
unsafe impl HasSimpleFFI for PerDocumentStyleData {}
unsafe impl HasBoxFFI for PerDocumentStyleData {}
-
-impl Drop for PerDocumentStyleDataImpl {
- fn drop(&mut self) {
- let _ = self.work_queue.take();
- }
-}
diff --git a/components/style/lib.rs b/components/style/lib.rs
index 6954c0fe3e7..d94f5436b51 100644
--- a/components/style/lib.rs
+++ b/components/style/lib.rs
@@ -61,7 +61,6 @@ extern crate matches;
#[cfg(feature = "gecko")] extern crate nsstring_vendor as nsstring;
extern crate num_integer;
extern crate num_traits;
-#[cfg(feature = "gecko")] extern crate num_cpus;
extern crate ordered_float;
extern crate owning_ref;
extern crate parking_lot;