[turbopack-trace-server] optimize loading (#93264)
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
Showing
This diff is collapsed.
Please
register
or
sign in
to comment