Skip to content

Commit

Permalink
add heaptrack trace format (#7849)
Browse files Browse the repository at this point in the history
### Description

allow to load heaptrack files with the turbo-trace-viewer

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes PACK-2848
  • Loading branch information
sokra committed Mar 30, 2024
1 parent 941bc0b commit e41c412
Show file tree
Hide file tree
Showing 11 changed files with 880 additions and 154 deletions.
2 changes: 2 additions & 0 deletions crates/turbopack-trace-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ intervaltree = "0.2.7"
itertools = { workspace = true }
owo-colors = { workspace = true }
postcard = { workspace = true }
rustc-demangle = "0.1"
serde = { workspace = true }
serde_json = { workspace = true }
turbopack-trace-utils = { workspace = true }
websocket = { version = "0.27.0", features = ["sync"] }
zstd = { version = "0.13.0" }
8 changes: 6 additions & 2 deletions crates/turbopack-trace-server/src/bottom_up.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, sync::Arc};
use std::{collections::HashMap, env, sync::Arc};

use either::Either;

Expand Down Expand Up @@ -38,6 +38,10 @@ impl SpanBottomUpBuilder {
pub fn build_bottom_up_graph<'a>(
spans: impl IntoIterator<Item = SpanRef<'a>>,
) -> Vec<Arc<SpanBottomUp>> {
let max_depth = env::var("BOTTOM_UP_DEPTH")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(usize::MAX);
let mut roots = HashMap::new();
let mut current_iterators = vec![Either::Left(
spans.into_iter().flat_map(|span| span.children()),
Expand All @@ -54,7 +58,7 @@ pub fn build_bottom_up_graph<'a>(
.or_insert_with(|| (name.to_string(), SpanBottomUpBuilder::new(child.index())));
bottom_up.self_spans.push(child.index());
let mut prev = None;
for &(name, example_span) in current_path.iter().rev() {
for &(name, example_span) in current_path.iter().rev().take(max_depth) {
if prev == Some(name) {
continue;
}
Expand Down
Loading

0 comments on commit e41c412

Please sign in to comment.