mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Rewrite the style sharing candidate cache.
The style candidate cache had regressed a few times (see #12534), and my intuition is that being able to disable all style sharing with a single rule in the page is really unfortunate. This commit redesigns the style sharing cache in order to be a optimistic cache, but then reject candidates if they match different sibling-affecting selectors in the page, for example. So far the numbers have improved, but not so much as I'd wanted (~10%/20% of non-incremental restyling time in general). The current implementation is really dumb though (we recompute and re-match a lot of stuff), so we should be able to optimise it quite a bit. I have different ideas for improving it (that may or may not work), apart of the low-hanging fruit like don't re-matching candidates all the time but I have to measure the real impact. Also, I need to verify it against try.
This commit is contained in:
parent
ec53136863
commit
3af774bd75
23 changed files with 467 additions and 236 deletions
10
ports/cef/Cargo.lock
generated
10
ports/cef/Cargo.lock
generated
|
@ -1070,7 +1070,7 @@ dependencies = [
|
|||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_layout_interface 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1783,7 +1783,7 @@ dependencies = [
|
|||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_layout_interface 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1820,7 +1820,7 @@ dependencies = [
|
|||
"profile_traits 0.0.1",
|
||||
"range 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1859,7 +1859,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "selectors"
|
||||
version = "0.8.2"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2122,7 +2122,7 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
8
ports/geckolib/Cargo.lock
generated
8
ports/geckolib/Cargo.lock
generated
|
@ -11,7 +11,7 @@ dependencies = [
|
|||
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
"style_traits 0.0.1",
|
||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -170,7 +170,7 @@ dependencies = [
|
|||
"gecko_bindings 0.0.1",
|
||||
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -311,7 +311,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "selectors"
|
||||
version = "0.8.2"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -367,7 +367,7 @@ dependencies = [
|
|||
"ordered-float 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style_traits 0.0.1",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -19,7 +19,7 @@ lazy_static = "0.2"
|
|||
libc = "0.2"
|
||||
log = {version = "0.3.5", features = ["release_max_level_info"]}
|
||||
num_cpus = "0.2.2"
|
||||
selectors = "0.8"
|
||||
selectors = "0.9"
|
||||
style = {path = "../../components/style", features = ["gecko"]}
|
||||
style_traits = {path = "../../components/style_traits"}
|
||||
url = "1.2"
|
||||
|
|
|
@ -14,5 +14,5 @@ cfg-if = "0.1.0"
|
|||
gecko_bindings = {version = "0.0.1", path = "../gecko_bindings"}
|
||||
heapsize = "0.3.5"
|
||||
libc = "0.2"
|
||||
selectors = "0.8"
|
||||
selectors = "0.9"
|
||||
serde = "0.8"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use context::StandaloneStyleContext;
|
||||
use std::mem;
|
||||
use style::context::SharedStyleContext;
|
||||
use style::context::{LocalStyleContext, SharedStyleContext, StyleContext};
|
||||
use style::dom::OpaqueNode;
|
||||
use style::traversal::RestyleResult;
|
||||
use style::traversal::{DomTraversalContext, recalc_style_at};
|
||||
|
@ -42,4 +42,8 @@ impl<'lc, 'ln> DomTraversalContext<GeckoNode<'ln>> for RecalcStyleOnly<'lc> {
|
|||
|
||||
/// We don't use the post-order traversal for anything.
|
||||
fn needs_postorder_traversal(&self) -> bool { false }
|
||||
|
||||
fn local_context(&self) -> &LocalStyleContext {
|
||||
self.context.local_context()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -459,6 +459,12 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'le> PartialEq for GeckoElement<'le> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.element == other.element
|
||||
}
|
||||
}
|
||||
|
||||
impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> {
|
||||
fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, _hints: &mut V)
|
||||
where V: Push<DeclarationBlock<Vec<PropertyDeclaration>>>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue