mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Land a few optimizations to the trace server
* Change `SpanEvent` so it is 32 bytes instead of 40 bytes by triggering a `niche` optimization
* Change `args` and `events` to be a `smallvec` with inline size 1
* for `args` it is size <=1 ~31% of the time
* for `events` it is size <=1 69% of the time
* Compute min/max timestamps in a single pass instead of 2 when inserting into the selftimetree
* Bundle dynamically computed 'total' fields behind a single OnceLock
* saves 40 bytes per span due to `Oncelock` overheads
* Inline SpanTimeData and SpanNames into Span
* We get little benefit from deferring the allocations and by inlining we save time and improve memory locality.
* post load SpanTimeData is allocated for 94% of spans, but after loading `trace.nextjs.org` it is 100%
* post load SpanNames is allocated for 0% of spans, but after loading it is 96.2% of spans
* Remove the `inner` `OnceLocks` from `SpanNames` we can just allocate these all together
Measuring with one 10gb trace file I see loading times progress from 75.7s (33G of ram) to 60.5s (19.5G of ram). With loading times hitting >200mb/s occasionally
37 lines
981 B
TOML
37 lines
981 B
TOML
[package]
|
|
name = "turbopack-trace-server"
|
|
version = "0.1.0"
|
|
description = "TBD"
|
|
license = "MIT"
|
|
edition = "2024"
|
|
autobenches = false
|
|
|
|
[features]
|
|
default = ["custom_allocator"]
|
|
custom_allocator = ["turbo-tasks-malloc/custom_allocator"]
|
|
|
|
[[bin]]
|
|
name = "turbo-trace-server"
|
|
path = "src/main.rs"
|
|
bench = false
|
|
|
|
[dependencies]
|
|
anyhow = { workspace = true }
|
|
either = { workspace = true }
|
|
flate2 = { workspace = true }
|
|
hashbrown = { workspace = true, features = ["raw"] }
|
|
indexmap = { workspace = true, features = ["serde"] }
|
|
itertools = { workspace = true }
|
|
postcard = { workspace = true }
|
|
rayon = { workspace = true }
|
|
rustc-demangle = "0.1"
|
|
rustc-hash = { workspace = true }
|
|
serde = { workspace = true }
|
|
serde_json = { workspace = true }
|
|
smallvec = { workspace = true }
|
|
turbo-rcstr = { workspace = true }
|
|
turbo-tasks-malloc = { workspace = true, default-features = false }
|
|
tungstenite = { version = "0.21.0" }
|
|
turbopack-trace-utils = { workspace = true }
|
|
zstd = { version = "0.13.0" }
|