Unverified Commit b46ffa94 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

[Turbopack] reduce the number of spans created in task completion (#75437)

### What?

Skip some methods for tasks without children.

Reduces number of spans created in tracing.
parent 23e86402
...@@ -1226,12 +1226,16 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1226,12 +1226,16 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
let mut removed_data = Vec::new(); let mut removed_data = Vec::new();
let mut old_edges = Vec::new(); let mut old_edges = Vec::new();
let has_children = !new_children.is_empty();
// Prepare all new children // Prepare all new children
prepare_new_children(task_id, &mut task, &new_children, &mut queue); if has_children {
prepare_new_children(task_id, &mut task, &new_children, &mut queue);
}
// Filter actual new children // Filter actual new children
for old_child in iter_many!(task, Child { task } => task) { for old_child in iter_many!(task, Child { task } => task) {
if !new_children.remove(&old_child) { if !has_children || !new_children.remove(&old_child) {
old_edges.push(OutdatedEdge::Child(old_child)); old_edges.push(OutdatedEdge::Child(old_child));
} }
} }
...@@ -1296,7 +1300,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1296,7 +1300,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
drop(task); drop(task);
{ if !queue.is_empty() || !old_edges.is_empty() {
let _span = tracing::trace_span!("remove old edges and prepare new children").entered(); let _span = tracing::trace_span!("remove old edges and prepare new children").entered();
// Remove outdated edges first, before removing in_progress+dirty flag. // Remove outdated edges first, before removing in_progress+dirty flag.
// We need to make sure all outdated edges are removed before the task can potentially // We need to make sure all outdated edges are removed before the task can potentially
...@@ -1344,19 +1348,21 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1344,19 +1348,21 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
let mut queue = AggregationUpdateQueue::new(); let mut queue = AggregationUpdateQueue::new();
let has_active_count = if has_children {
get!(task, Activeness).map_or(false, |activeness| activeness.active_counter > 0); let has_active_count =
connect_children( get!(task, Activeness).map_or(false, |activeness| activeness.active_counter > 0);
task_id, connect_children(
&mut task, task_id,
new_children, &mut task,
&mut queue, new_children,
has_active_count, &mut queue,
); has_active_count,
);
}
drop(task); drop(task);
{ if has_children {
let _span = tracing::trace_span!("connect new children").entered(); let _span = tracing::trace_span!("connect new children").entered();
queue.execute(&mut ctx); queue.execute(&mut ctx);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment