mirror of
https://github.com/servo/servo.git
synced 2025-07-08 07:53:40 +01:00
geckolib: move NUM_THREADS from style to geckolib
This change eliminates some gecko-only configuration in the style component and moves NUM_THREADS closer to its only uses.
This commit is contained in:
parent
3e81f8431e
commit
fafcdda16a
6 changed files with 15 additions and 21 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2719,7 +2719,6 @@ dependencies = [
|
||||||
"nsstring_vendor 0.1.0",
|
"nsstring_vendor 0.1.0",
|
||||||
"num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -13,7 +13,7 @@ path = "lib.rs"
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
gecko = ["nsstring_vendor", "num_cpus", "rayon/unstable"]
|
gecko = ["nsstring_vendor", "rayon/unstable"]
|
||||||
use_bindgen = ["bindgen", "regex"]
|
use_bindgen = ["bindgen", "regex"]
|
||||||
servo = ["serde/unstable", "serde", "serde_derive", "heapsize_derive",
|
servo = ["serde/unstable", "serde", "serde_derive", "heapsize_derive",
|
||||||
"style_traits/servo", "servo_atoms", "html5ever-atoms",
|
"style_traits/servo", "servo_atoms", "html5ever-atoms",
|
||||||
|
@ -57,10 +57,6 @@ servo_url = {path = "../url"}
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
unicode-segmentation = "1.0"
|
unicode-segmentation = "1.0"
|
||||||
|
|
||||||
[dependencies.num_cpus]
|
|
||||||
optional = true
|
|
||||||
version = "1.0"
|
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
kernel32-sys = "0.2"
|
kernel32-sys = "0.2"
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,9 @@ use gecko_bindings::bindings::RawServoStyleSet;
|
||||||
use gecko_bindings::structs::RawGeckoPresContextOwned;
|
use gecko_bindings::structs::RawGeckoPresContextOwned;
|
||||||
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||||
use media_queries::Device;
|
use media_queries::Device;
|
||||||
use num_cpus;
|
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use properties::ComputedValues;
|
use properties::ComputedValues;
|
||||||
use std::cmp;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||||
use stylesheets::Stylesheet;
|
use stylesheets::Stylesheet;
|
||||||
|
@ -53,16 +50,6 @@ pub struct PerDocumentStyleDataImpl {
|
||||||
/// and unexpected races while trying to mutate it.
|
/// and unexpected races while trying to mutate it.
|
||||||
pub struct PerDocumentStyleData(AtomicRefCell<PerDocumentStyleDataImpl>);
|
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 {
|
impl PerDocumentStyleData {
|
||||||
/// Create a dummy `PerDocumentStyleData`.
|
/// Create a dummy `PerDocumentStyleData`.
|
||||||
pub fn new(pres_context: RawGeckoPresContextOwned) -> Self {
|
pub fn new(pres_context: RawGeckoPresContextOwned) -> Self {
|
||||||
|
|
|
@ -61,7 +61,6 @@ extern crate matches;
|
||||||
#[cfg(feature = "gecko")] extern crate nsstring_vendor as nsstring;
|
#[cfg(feature = "gecko")] extern crate nsstring_vendor as nsstring;
|
||||||
extern crate num_integer;
|
extern crate num_integer;
|
||||||
extern crate num_traits;
|
extern crate num_traits;
|
||||||
#[cfg(feature = "gecko")] extern crate num_cpus;
|
|
||||||
extern crate ordered_float;
|
extern crate ordered_float;
|
||||||
extern crate owning_ref;
|
extern crate owning_ref;
|
||||||
extern crate parking_lot;
|
extern crate parking_lot;
|
||||||
|
|
|
@ -8,11 +8,13 @@ use cssparser::Parser;
|
||||||
use cssparser::ToCss as ParserToCss;
|
use cssparser::ToCss as ParserToCss;
|
||||||
use env_logger::LogBuilder;
|
use env_logger::LogBuilder;
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
|
use num_cpus;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use rayon;
|
use rayon;
|
||||||
use selectors::Element;
|
use selectors::Element;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::cmp;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -24,7 +26,7 @@ use style::context::{ThreadLocalStyleContext, ThreadLocalStyleContextCreationInf
|
||||||
use style::data::{ElementData, ElementStyles, RestyleData};
|
use style::data::{ElementData, ElementStyles, RestyleData};
|
||||||
use style::dom::{ShowSubtreeData, TElement, TNode};
|
use style::dom::{ShowSubtreeData, TElement, TNode};
|
||||||
use style::error_reporting::StdoutErrorReporter;
|
use style::error_reporting::StdoutErrorReporter;
|
||||||
use style::gecko::data::{NUM_THREADS, PerDocumentStyleData, PerDocumentStyleDataImpl};
|
use style::gecko::data::{PerDocumentStyleData, PerDocumentStyleDataImpl};
|
||||||
use style::gecko::restyle_damage::GeckoRestyleDamage;
|
use style::gecko::restyle_damage::GeckoRestyleDamage;
|
||||||
use style::gecko::selector_parser::{SelectorImpl, PseudoElement};
|
use style::gecko::selector_parser::{SelectorImpl, PseudoElement};
|
||||||
use style::gecko::traversal::RecalcStyleOnly;
|
use style::gecko::traversal::RecalcStyleOnly;
|
||||||
|
@ -91,6 +93,16 @@ use stylesheet_loader::StylesheetLoader;
|
||||||
* depend on but good enough for our purposes.
|
* depend on but good enough for our purposes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
/// The number of layout threads, computed statically.
|
||||||
|
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),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref STYLE_THREAD_POOL: Option<rayon::ThreadPool> = {
|
static ref STYLE_THREAD_POOL: Option<rayon::ThreadPool> = {
|
||||||
let num_threads = *NUM_THREADS;
|
let num_threads = *NUM_THREADS;
|
||||||
|
|
|
@ -12,6 +12,7 @@ extern crate euclid;
|
||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
extern crate num_cpus;
|
||||||
extern crate parking_lot;
|
extern crate parking_lot;
|
||||||
extern crate rayon;
|
extern crate rayon;
|
||||||
extern crate selectors;
|
extern crate selectors;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue