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

This commit is contained in:
Emilio Cobos Álvarez 2017-07-23 01:47:47 +02:00
parent b576229567
commit 1c5d522742
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

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);
}); });
}); });
}); });