diff options
author | bors-servo <release+servo@mozilla.com> | 2014-02-14 20:47:01 -0500 |
---|---|---|
committer | bors-servo <release+servo@mozilla.com> | 2014-02-14 20:47:01 -0500 |
commit | 425210b9b404ca769037879f9c2a01c63a0375c8 (patch) | |
tree | b6c729586d4a2f9392f203b8bac91448e7d763fd /src/components/main/layout/layout_task.rs | |
parent | 6b89cbf3c508a9a19469e9b95d72026fc837661c (diff) | |
parent | d3e56fa9cc479b242e8c322cc6e1bbd8e7cb1070 (diff) | |
download | servo-425210b9b404ca769037879f9c2a01c63a0375c8.tar.gz servo-425210b9b404ca769037879f9c2a01c63a0375c8.zip |
auto merge of #1644 : pcwalton/servo/style-sharing, r=larsbergstrom
This series of patches implements style struct sharing as found in existing browser engines, as well as a bunch of related important optimizations. With them, we are faster than Blink, WebKit, and Gecko on the rainbow page for style recalc in sequential mode by at least 15%. Parallel gains are mixed—the rainbow page turns out to be a degenerate sequential case for the LRU cache used to track candidates for style sharing and so there is no improvement. For cases in which the cache is not hit, such as `perf-rainbow-hard.html`, we are around 25% slower than Blink sequentially, but have very large parallel wins so that we are around 2x faster at style recalc. (Note that parallel flow tree construction will improve this further.)
This patch series also fixes, as near as I can tell, some bugs related to ordering of properties that other properties depend on in selector matching.
r? @larsbergstrom
feedback? @SimonSapin (for selector matching changes)
feedback? @bzbarsky (for style sharing heuristics)
Diffstat (limited to 'src/components/main/layout/layout_task.rs')
-rw-r--r-- | src/components/main/layout/layout_task.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs index 733ca093fb8..2d79208b6ed 100644 --- a/src/components/main/layout/layout_task.rs +++ b/src/components/main/layout/layout_task.rs @@ -5,7 +5,8 @@ //! The layout task. Performs layout on the DOM, builds display lists and sends them to be /// rendered. -use css::matching::MatchMethods; +use css::matching::{ApplicableDeclarations, ApplicableDeclarationsCache, MatchMethods}; +use css::matching::{StyleSharingCandidateCache}; use css::select::new_stylist; use css::node_style::StyledNode; use layout::construct::{FlowConstructionResult, FlowConstructor, NoConstructionResult}; @@ -55,7 +56,8 @@ use std::comm::Port; use std::ptr; use std::task; use std::util; -use style::{AuthorOrigin, Stylesheet, Stylist}; +use style::{AuthorOrigin, ComputedValues, Stylesheet, Stylist}; +use style; /// Information needed by the layout task. pub struct LayoutTask { @@ -97,6 +99,9 @@ pub struct LayoutTask { stylist: ~Stylist, + /// The initial set of CSS values. + initial_css_values: Arc<ComputedValues>, + /// The workers that we use for parallel operation. parallel_traversal: Option<WorkQueue<*mut LayoutContext,UnsafeFlow>>, @@ -302,6 +307,7 @@ impl LayoutTask { display_list_collection: None, stylist: ~new_stylist(), + initial_css_values: Arc::new(style::initial_values()), parallel_traversal: parallel_traversal, profiler_chan: profiler_chan, opts: opts.clone() @@ -332,6 +338,7 @@ impl LayoutTask { layout_chan: self.chan.clone(), font_context_info: font_context_info, stylist: &*self.stylist, + initial_css_values: self.initial_css_values.clone(), reflow_root: OpaqueNode::from_layout_node(reflow_root), } } @@ -561,8 +568,17 @@ impl LayoutTask { profile(time::LayoutSelectorMatchCategory, self.profiler_chan.clone(), || { match self.parallel_traversal { None => { + let mut applicable_declarations = ApplicableDeclarations::new(); + let mut applicable_declarations_cache = + ApplicableDeclarationsCache::new(); + let mut style_sharing_candidate_cache = + StyleSharingCandidateCache::new(); node.match_and_cascade_subtree(self.stylist, &layout_ctx.layout_chan, + &mut applicable_declarations, + layout_ctx.initial_css_values.get(), + &mut applicable_declarations_cache, + &mut style_sharing_candidate_cache, None) } Some(ref mut traversal) => { @@ -636,6 +652,7 @@ impl LayoutTask { .resolve_color(thread_safe_child.style() .get() .Background + .get() .background_color) .to_gfx_color() }; |