Trace active Tokio worker threads with memory samples (#99233)
## What? Record the number of non-idle Tokio scheduler worker threads alongside Turbopack's existing process-memory samples. The span-query API and MCP output expose it as the fourth value in each memory sample. The WebSocket query result adds a parallel worker series for visualization in [vercel/turbo-trace-viewer#33](https://github.com/vercel/turbo-trace-viewer/pull/33), retaining the original memory-only series. ## Why? Memory samples alone do not show whether Tokio's workers were busy or parked at a given point in a trace. The aligned worker count makes it easier to correlate memory changes and traced work with scheduler activity. ## How? Each traced runtime builder initializes one global atomic counter with its worker capacity, then Tokio's worker-only park/unpark callbacks adjust it. This avoids counting blocking-pool threads and assumes one traced Tokio runtime per process; shutdown bookkeeping is unnecessary for this metric. The counter is read at the existing memory-sampling cadence rather than emitting trace rows on each worker transition. Trace ingestion, span-query downsampling, and the WebSocket worker series preserve the count from the same sample as the selected memory value. ## Verification - `cargo test --locked -p turbopack-trace-utils -p turbopack-trace-server` - `cargo check --locked -p turbopack-cli -p turbopack-nft -p next-build-test -p next-napi-bindings` - `cargo fmt --all -- --check`; `git diff --check` - Not run: Next.js TypeScript/prettier/full build (checkout has no `node_modules`). <!-- NEXT_JS_LLM --> <!-- fleet 0c297c2c-8e55-4012-be8a-752ff8175d1b --> --------- Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment