Add MemorySample to Turbopack trace infrastructure#90597
Draft
Add MemorySample to Turbopack trace infrastructure#90597
Conversation
Captures TurboMalloc::memory_usage() at ~10ms intervals from on_enter, using a three-tier dedup strategy (thread-local → global atomic → CAS) to minimize overhead in hot paths.
Store all MemorySample trace rows in a sorted list in the Store. When a span is queried, return up to 200 memory samples covering the span's [start, end] range. When more samples exist, merge groups of N by taking the max memory value per group.
Merging this PR will not alter performance
Comparing Footnotes
|
Collaborator
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles: **400 kB** → **400 kB** ✅ -13 B80 files with content-based hashes (individual files not comparable between builds) Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Adds periodic process memory sampling to the Turbopack trace system.
Two new capabilities:
TraceRow::MemorySample— A new trace row variant that capturesTurboMalloc::memory_usage()at ~10ms intervalsmemory_samplesinQueryResult— When querying a span, returns up to 200 memory usage samples covering the span's time rangeWhy?
To provide visibility into process memory usage over time in the Turbopack trace viewer. Currently the trace system tracks per-span allocations/deallocations but has no global memory usage timeline.
How?
Sampling (
turbopack-trace-utils):TraceRow::MemorySample { ts, memory }varianton_enterusing a three-tier dedup strategy to minimize overhead:Storage (
turbopack-trace-server):Vec<(Timestamp, u64)>in theStoreQuery (
turbopack-trace-server):memory_samples_for_range(start, end)returns up to 200 samplesmemory_samples: Vec<u64>field toQueryResult