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

[Turbopack] sort spans by start date in tracing (#75642)

### What?

Due to the thread local buffer of spans it happens that they are in unexpected order in the trace file. This sorts them by start date.
parent a2814731
...@@ -659,7 +659,7 @@ impl Viewer { ...@@ -659,7 +659,7 @@ impl Viewer {
Reverse(value_mode.value_from_span(child)) Reverse(value_mode.value_from_span(child))
})) }))
} else { } else {
Either::Right(span.children()) Either::Right(span.children().sorted_by_key(|child| child.start()))
}; };
for child in spans { for child in spans {
let filtered = get_filter_mode(child.id()); let filtered = get_filter_mode(child.id());
...@@ -749,7 +749,7 @@ impl Viewer { ...@@ -749,7 +749,7 @@ impl Viewer {
Reverse(value_mode.value_from_bottom_up_span(child)) Reverse(value_mode.value_from_bottom_up_span(child))
})) }))
} else { } else {
Either::Right(bottom_up) Either::Right(bottom_up.sorted_by_key(|child| child.start()))
}; };
for child in bottom_up { for child in bottom_up {
let filtered = get_filter_mode(child.id()); let filtered = get_filter_mode(child.id());
...@@ -771,7 +771,9 @@ impl Viewer { ...@@ -771,7 +771,9 @@ impl Viewer {
Reverse(value_mode.value_from_span(child)) Reverse(value_mode.value_from_span(child))
})) }))
} else { } else {
Either::Right(span_graph.root_spans()) Either::Right(
span_graph.root_spans().sorted_by_key(|child| child.start()),
)
}; };
for child in spans { for child in spans {
let filtered = get_filter_mode(child.id()); let filtered = get_filter_mode(child.id());
...@@ -850,7 +852,7 @@ impl Viewer { ...@@ -850,7 +852,7 @@ impl Viewer {
Reverse(value_mode.value_from_bottom_up_span(child)) Reverse(value_mode.value_from_bottom_up_span(child))
})) }))
} else { } else {
Either::Right(bottom_up.spans()) Either::Right(bottom_up.spans().sorted_by_key(|child| child.start()))
}; };
for child in spans { for child in spans {
let filtered = get_filter_mode(child.id()); let filtered = get_filter_mode(child.id());
......
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