Unverified Commit 2b04d2ee authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: make GraphTraversal deterministically calling all nodes before erroring (#88119)

### What?

The graph traversal used to early exit when there are errors. This leads to cycles to continuously executing the graph traversal to discover more task one by one. This leads to bad incremental performance.
parent 77071f90
......@@ -8,6 +8,4 @@ pub enum VisitControlFlow {
/// The edge is excluded, and the traversal should not continue on the outgoing edges of the
/// given node.
Exclude,
/// The traversal should abort and return immediately.
Abort,
}
......@@ -42,7 +42,6 @@ where
Impl: Send,
{
let mut futures = FuturesUnordered::new();
let mut is_abort = false;
// Populate `futures` with all the roots, `root_nodes` isn't required to be `Send`, so this
// has to happen outside of the future. We could require `root_nodes` to be `Send` in the
......@@ -62,18 +61,11 @@ where
VisitControlFlow::Exclude => {
// do nothing
}
VisitControlFlow::Abort => {
// this must be returned inside the `async` block below so that it's part of the
// returned future
is_abort = true;
}
}
}
async move {
if is_abort {
return GraphTraversalResult::Aborted;
}
let mut result = Ok(());
loop {
match futures.next().await {
Some((parent_node, span, Ok(edges))) => {
......@@ -94,17 +86,14 @@ where
VisitControlFlow::Exclude => {
// do nothing
}
VisitControlFlow::Abort => {
return GraphTraversalResult::Aborted;
}
}
}
}
Some((_, _, Err(err))) => {
return GraphTraversalResult::Completed(Err(err));
result = Err(err);
}
None => {
return GraphTraversalResult::Completed(Ok(self));
return GraphTraversalResult::Completed(result.map(|()| self));
}
}
}
......@@ -114,14 +103,12 @@ where
pub enum GraphTraversalResult<Completed> {
Completed(Completed),
Aborted,
}
impl<Completed> GraphTraversalResult<Completed> {
pub fn completed(self) -> Completed {
match self {
GraphTraversalResult::Completed(completed) => completed,
GraphTraversalResult::Aborted => panic!("Graph traversal was aborted"),
}
}
}
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