turbopack: use Bitset in collect_graph (#100567)
Stacked on #100643 (`compute_chunk_group_info`), on top of #100566, which adds `turbo-bitset`. Stack: #100566 → #100643 → this → #100568 → #100630. ## Summary `collect_graph` now uses `Bitset` for its per-module entry membership sets during the fixed-point traversal, the same change as in `compute_chunk_group_info`. It never stores these sets, so nothing needs converting back to `RoaringBitmapWrapper`. Like #100643, it drops the first-visit `is_zero()` check plus `clone()`, as `union_with` copies into a set that stores no blocks. When matching collected references to entries, the old code built a Roaring intersection of the collecting module's and the emitted module's memberships. It now walks the collecting module's entries and keeps those that the emitted module's membership `contains`. That allocates no intermediate set, and the order and the skip-when-empty behavior are unchanged. ## Benchmarks > **Historical, not rerun:** measured in the previous review round, before this stack was rebased onto canary `502b6b7d` and before the latest review changes on `b149cf8a` (#100566), `c7ea9063` (#100643), `e322a1c1` (#100567), `6536eeea` (#100568) and `417a41fd` (#100630). This round only reran the `turbo-bitset` microbenchmarks in #100566. `next build --experimental-build-mode compile` with release `next-swc` (LTO off, 16 codegen units) built from each PR's head plus local-only stage timers, on a shared VM with 8 vCPUs and 16 GB. Each number is the median of 5 randomized, interleaved runs per variant, with the min–max range in parentheses, in ms. All five layers of the stack were measured in the same interleaved set, so adjacent PRs compare directly. | stage (ms) | previous PR | this PR | |---|---|---| | `bench/nested-deps-app-router-many-pages` (3,000 routes): `collect_graph` fixed point | 189 (186–195) | **16 (15–17.1)** | | generated 300-route app: `collect_graph` fixed point | 6.38 (6.32–6.68) | **3.37 (3.33–4.02)** | Visit counts are identical, and the emitted JS chunks are byte-identical across all layers of the stack on both apps. Whole-build time is too noisy on these apps to show a reliable end-to-end difference. <details> <summary>Charts: stage times (linear)</summary> Median ms per stage; the first series is the previous PR. Exact values and ranges are in the table above. ```mermaid xychart-beta title "bench/nested-deps-app-router-many-pages, median ms" x-axis ["`collect_graph` fixed point"] y-axis "ms" bar "previous PR" [189] bar "this PR" [16] ``` ```mermaid xychart-beta title "generated 300-route app, median ms" x-axis ["`collect_graph` fixed point"] y-axis "ms" bar "previous PR" [6.38] bar "this PR" [3.37] ``` </details> ## Verification - `cargo test -p turbopack-core --lib`, the turbopack snapshot tests and the collect execution tests pass. All execution tests pass on the top of the stack. - The real builds above. <!-- NEXT_JS_LLM --> <!-- fleet b56269ed-2145-4f30-b0fe-dc9762520521 --> --------- Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com> Co-authored-by:
Vercel Fleet <fleet@vercel.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment