layout: Profile layout damage propagation and group "style recalc" (as

WebKit calls it) into one supercategory in the profiler
This commit is contained in:
Patrick Walton 2014-01-29 11:41:22 -08:00
parent 6c63de1c03
commit 21656b874d
2 changed files with 54 additions and 37 deletions

View file

@ -508,6 +508,9 @@ impl LayoutTask {
// Create a layout context for use throughout the following passes.
let mut layout_ctx = self.build_layout_context(node);
let mut layout_root = profile(time::LayoutStyleRecalcCategory,
self.profiler_chan.clone(),
|| {
// Initialize layout data for each node.
//
// FIXME: This is inefficient. We don't need an entire traversal to do this!
@ -540,15 +543,18 @@ impl LayoutTask {
}
// Construct the flow tree.
let mut layout_root = profile(time::LayoutTreeBuilderCategory,
profile(time::LayoutTreeBuilderCategory,
self.profiler_chan.clone(),
|| self.construct_flow_tree(&mut layout_ctx, *node));
|| self.construct_flow_tree(&mut layout_ctx, *node))
});
// Propagate damage.
profile(time::LayoutDamagePropagateCategory, self.profiler_chan.clone(), || {
layout_root.traverse_preorder(&mut PropagateDamageTraversal {
all_style_damage: all_style_damage
});
layout_root.traverse_postorder(&mut ComputeDamageTraversal.clone());
});
// Perform the primary layout passes over the flow tree to compute the locations of all
// the boxes.

View file

@ -50,10 +50,12 @@ pub enum ProfilerCategory {
CompositingCategory,
LayoutQueryCategory,
LayoutPerformCategory,
LayoutStyleRecalcCategory,
LayoutAuxInitCategory,
LayoutSelectorMatchCategory,
LayoutSelectorCascadeCategory,
LayoutTreeBuilderCategory,
LayoutDamagePropagateCategory,
LayoutMainCategory,
LayoutParallelWarmupCategory,
LayoutShapingCategory,
@ -78,6 +80,7 @@ impl ProfilerCategory {
buckets.insert(CompositingCategory, ~[]);
buckets.insert(LayoutQueryCategory, ~[]);
buckets.insert(LayoutPerformCategory, ~[]);
buckets.insert(LayoutStyleRecalcCategory, ~[]);
buckets.insert(LayoutAuxInitCategory, ~[]);
buckets.insert(LayoutSelectorMatchCategory, ~[]);
buckets.insert(LayoutSelectorCascadeCategory, ~[]);
@ -85,6 +88,7 @@ impl ProfilerCategory {
buckets.insert(LayoutMainCategory, ~[]);
buckets.insert(LayoutParallelWarmupCategory, ~[]);
buckets.insert(LayoutShapingCategory, ~[]);
buckets.insert(LayoutDamagePropagateCategory, ~[]);
buckets.insert(LayoutDispListBuildCategory, ~[]);
buckets.insert(GfxRegenAvailableFontsCategory, ~[]);
buckets.insert(RenderingDrawingCategory, ~[]);
@ -98,9 +102,16 @@ impl ProfilerCategory {
// and should be printed to indicate this
pub fn format(self) -> ~str {
let padding = match self {
LayoutAuxInitCategory | LayoutSelectorMatchCategory | LayoutSelectorCascadeCategory |
LayoutTreeBuilderCategory | LayoutMainCategory | LayoutDispListBuildCategory |
LayoutShapingCategory | LayoutParallelWarmupCategory => " - ",
LayoutStyleRecalcCategory |
LayoutMainCategory |
LayoutDispListBuildCategory |
LayoutShapingCategory |
LayoutDamagePropagateCategory => "+ ",
LayoutAuxInitCategory |
LayoutSelectorCascadeCategory |
LayoutParallelWarmupCategory |
LayoutSelectorMatchCategory |
LayoutTreeBuilderCategory => "| + ",
_ => ""
};
format!("{:s}{:?}", padding, self)
@ -190,7 +201,7 @@ impl Profiler {
}
fn print_buckets(&mut self) {
println(format!("{:31s} {:15s} {:15s} {:15s} {:15s} {:15s}",
println(format!("{:39s} {:15s} {:15s} {:15s} {:15s} {:15s}",
"_category_", "_mean (ms)_", "_median (ms)_",
"_min (ms)_", "_max (ms)_", "_bucket size_"));
for (category, data) in self.buckets.iter() {
@ -210,7 +221,7 @@ impl Profiler {
data[data_len / 2],
data.iter().min().unwrap(),
data.iter().max().unwrap());
println(format!("{:-30s}: {:15.4f} {:15.4f} {:15.4f} {:15.4f} {:15u}",
println(format!("{:-35s}: {:15.4f} {:15.4f} {:15.4f} {:15.4f} {:15u}",
category.format(), mean, median, min, max, data_len));
}
}