Auto merge of #17824 - emilio:debug-par-layout, r=stshine

layout: Make -Z show-parallel-layout show something useful again.

I broke this when we switched to rayon, but now rayon added support for getting the worker index there's no reason for not bringing it back to life.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17824)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-22 17:50:21 -07:00 committed by GitHub
commit d0561e76df

View file

@ -127,6 +127,7 @@ fn buttom_up_flow(mut unsafe_flow: UnsafeFlow,
} }
fn top_down_flow<'scope>(unsafe_flows: &[UnsafeFlow], fn top_down_flow<'scope>(unsafe_flows: &[UnsafeFlow],
pool: &'scope rayon::ThreadPool,
scope: &rayon::Scope<'scope>, scope: &rayon::Scope<'scope>,
assign_isize_traversal: &'scope AssignISizes, assign_isize_traversal: &'scope AssignISizes,
assign_bsize_traversal: &'scope AssignBSizes) assign_bsize_traversal: &'scope AssignBSizes)
@ -138,13 +139,8 @@ fn top_down_flow<'scope>(unsafe_flows: &[UnsafeFlow],
unsafe { unsafe {
// Get a real flow. // Get a real flow.
let flow: &mut Flow = mem::transmute(*unsafe_flow); let flow: &mut Flow = mem::transmute(*unsafe_flow);
flow::mut_base(flow).thread_id =
// FIXME(emilio): With the switch to rayon we can no longer pool.current_thread_index().unwrap() as u8;
// access a thread id from here easily. Either instrument
// rayon (the unstable feature) to get a worker thread
// identifier, or remove all the layout tinting mode.
//
// flow::mut_base(flow).thread_id = proxy.worker_index();
if assign_isize_traversal.should_process(flow) { if assign_isize_traversal.should_process(flow) {
// Perform the appropriate traversal. // Perform the appropriate traversal.
@ -171,6 +167,7 @@ fn top_down_flow<'scope>(unsafe_flows: &[UnsafeFlow],
if discovered_child_flows.len() <= CHUNK_SIZE { if discovered_child_flows.len() <= CHUNK_SIZE {
// We can handle all the children in this work unit. // We can handle all the children in this work unit.
top_down_flow(&discovered_child_flows, top_down_flow(&discovered_child_flows,
pool,
scope, scope,
&assign_isize_traversal, &assign_isize_traversal,
&assign_bsize_traversal); &assign_bsize_traversal);
@ -181,11 +178,11 @@ fn top_down_flow<'scope>(unsafe_flows: &[UnsafeFlow],
for chunk in chunks { for chunk in chunks {
let nodes = chunk.iter().cloned().collect::<FlowList>(); let nodes = chunk.iter().cloned().collect::<FlowList>();
scope.spawn(move |scope| { scope.spawn(move |scope| {
top_down_flow(&nodes, scope, &assign_isize_traversal, &assign_bsize_traversal); top_down_flow(&nodes, pool, scope, &assign_isize_traversal, &assign_bsize_traversal);
}); });
} }
if let Some(chunk) = first_chunk { if let Some(chunk) = first_chunk {
top_down_flow(chunk, scope, &assign_isize_traversal, &assign_bsize_traversal); top_down_flow(chunk, pool, scope, &assign_isize_traversal, &assign_bsize_traversal);
} }
} }
} }
@ -209,7 +206,7 @@ pub fn traverse_flow_tree_preorder(
rayon::scope(move |scope| { rayon::scope(move |scope| {
profile(time::ProfilerCategory::LayoutParallelWarmup, profile(time::ProfilerCategory::LayoutParallelWarmup,
profiler_metadata, time_profiler_chan, move || { profiler_metadata, time_profiler_chan, move || {
top_down_flow(&nodes, scope, assign_isize_traversal, assign_bsize_traversal); top_down_flow(&nodes, queue, scope, assign_isize_traversal, assign_bsize_traversal);
}); });
}); });
}); });