Merge pull request #3379 from cgaebel/bucketed-timing

Added more complex profiling metadata.
This commit is contained in:
Clark Gaebel 2014-09-18 09:12:34 -07:00
commit 1b251db732
10 changed files with 123 additions and 69 deletions

View file

@ -58,6 +58,7 @@ use servo_util::time::{TimeProfilerChan, profile};
use servo_util::time;
use servo_util::task::spawn_named_with_send_on_failure;
use servo_util::workqueue::WorkQueue;
use std::cell::Cell;
use std::comm::{channel, Sender, Receiver, Select};
use std::mem;
use std::ptr;
@ -127,6 +128,9 @@ pub struct LayoutTask {
/// The command-line options.
pub opts: Opts,
/// Is this the first reflow in this LayoutTask?
pub first_reflow: Cell<bool>,
/// A mutex to allow for fast, read-only RPC of layout's internal data
/// structures, while still letting the LayoutTask modify them.
///
@ -400,6 +404,7 @@ impl LayoutTask {
image_cache_task: image_cache_task.clone(),
font_cache_task: font_cache_task,
opts: opts.clone(),
first_reflow: Cell::new(true),
rw_data: Arc::new(Mutex::new(
LayoutTaskData {
local_image_cache: local_image_cache,
@ -511,7 +516,8 @@ impl LayoutTask {
self.rw_data.clone()) as Box<LayoutRPC + Send>);
},
ReflowMsg(data) => {
profile(time::LayoutPerformCategory, self.time_profiler_chan.clone(), || {
profile(time::LayoutPerformCategory, Some((&data.url, data.iframe, self.first_reflow.get())),
self.time_profiler_chan.clone(), || {
self.handle_reflow(&*data, possibly_locked_rw_data);
});
},
@ -670,6 +676,7 @@ impl LayoutTask {
/// benchmarked against those two. It is marked `#[inline(never)]` to aid profiling.
#[inline(never)]
fn solve_constraints_parallel(&self,
data: &Reflow,
rw_data: &mut LayoutTaskData,
layout_root: &mut FlowRef,
shared_layout_context: &SharedLayoutContext) {
@ -686,6 +693,9 @@ impl LayoutTask {
// NOTE: this currently computes borders, so any pruning should separate that
// operation out.
parallel::traverse_flow_tree_preorder(layout_root,
&data.url,
data.iframe,
self.first_reflow.get(),
self.time_profiler_chan.clone(),
shared_layout_context,
traversal);
@ -755,6 +765,9 @@ impl LayoutTask {
&data.url);
let mut layout_root = profile(time::LayoutStyleRecalcCategory,
Some((&data.url,
data.iframe,
self.first_reflow.get())),
self.time_profiler_chan.clone(),
|| {
// Perform CSS selector matching and flow construction.
@ -789,7 +802,8 @@ impl LayoutTask {
}
// Propagate damage.
profile(time::LayoutDamagePropagateCategory, self.time_profiler_chan.clone(), || {
profile(time::LayoutDamagePropagateCategory, Some((&data.url, data.iframe, self.first_reflow.get())),
self.time_profiler_chan.clone(), || {
layout_root.get_mut().traverse_preorder(&mut PropagateDamageTraversal {
all_style_damage: all_style_damage
});
@ -798,7 +812,8 @@ impl LayoutTask {
// Perform the primary layout passes over the flow tree to compute the locations of all
// the boxes.
profile(time::LayoutMainCategory, self.time_profiler_chan.clone(), || {
profile(time::LayoutMainCategory, Some((&data.url, data.iframe, self.first_reflow.get())),
self.time_profiler_chan.clone(), || {
let rw_data = rw_data.deref_mut();
match rw_data.parallel_traversal {
None => {
@ -808,7 +823,7 @@ impl LayoutTask {
}
Some(_) => {
// Parallel mode.
self.solve_constraints_parallel(rw_data, &mut layout_root, &mut shared_layout_ctx)
self.solve_constraints_parallel(data, rw_data, &mut layout_root, &mut shared_layout_ctx)
}
}
});
@ -816,7 +831,7 @@ impl LayoutTask {
// Build the display list if necessary, and send it to the renderer.
if data.goal == ReflowForDisplay {
let writing_mode = flow::base(layout_root.get()).writing_mode;
profile(time::LayoutDispListBuildCategory, self.time_profiler_chan.clone(), || {
profile(time::LayoutDispListBuildCategory, Some((&data.url, data.iframe, self.first_reflow.get())), self.time_profiler_chan.clone(), || {
shared_layout_ctx.dirty = flow::base(layout_root.get()).position.to_physical(
writing_mode, rw_data.screen_size);
flow::mut_base(layout_root.get_mut()).abs_position =
@ -833,6 +848,9 @@ impl LayoutTask {
}
Some(ref mut traversal) => {
parallel::build_display_list_for_subtree(&mut layout_root,
&data.url,
data.iframe,
self.first_reflow.get(),
self.time_profiler_chan.clone(),
&mut shared_layout_ctx,
traversal);
@ -901,6 +919,8 @@ impl LayoutTask {
});
}
self.first_reflow.set(false);
if self.opts.trace_layout {
layout_debug::end_trace();
}

View file

@ -15,6 +15,7 @@ use flow;
use flow_ref::FlowRef;
use layout_task::{AssignBSizesAndStoreOverflowTraversal, AssignISizesTraversal};
use layout_task::{BubbleISizesTraversal};
use url::Url;
use util::{LayoutDataAccess, LayoutDataWrapper, OpaqueNodeMethods};
use wrapper::{layout_node_to_unsafe_layout_node, layout_node_from_unsafe_layout_node, LayoutNode, PostorderNodeMutTraversal};
use wrapper::{ThreadSafeLayoutNode, UnsafeLayoutNode};
@ -624,12 +625,15 @@ pub fn recalc_style_for_subtree(root_node: &LayoutNode,
}
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
url: &Url,
iframe: bool,
first_reflow: bool,
time_profiler_chan: TimeProfilerChan,
shared_layout_context: &SharedLayoutContext,
queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) {
queue.data = shared_layout_context as *const _;
profile(time::LayoutParallelWarmupCategory, time_profiler_chan, || {
profile(time::LayoutParallelWarmupCategory, Some((url, iframe, first_reflow)), time_profiler_chan, || {
queue.push(WorkUnit {
fun: assign_inline_sizes,
data: mut_owned_flow_to_unsafe_flow(root),
@ -642,12 +646,15 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
}
pub fn build_display_list_for_subtree(root: &mut FlowRef,
url: &Url,
iframe: bool,
first_reflow: bool,
time_profiler_chan: TimeProfilerChan,
shared_layout_context: &SharedLayoutContext,
queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) {
queue.data = shared_layout_context as *const _;
profile(time::LayoutParallelWarmupCategory, time_profiler_chan, || {
profile(time::LayoutParallelWarmupCategory, Some((url, iframe, first_reflow)), time_profiler_chan, || {
queue.push(WorkUnit {
fun: compute_absolute_position,
data: mut_owned_flow_to_unsafe_flow(root),