bundler: fix quadratic naming of unminified cross-chunk bindings that share a source name - #40569
Conversation
…ing unminified cross-chunk bindings assign_unminified probed name2, name3, ... from 2 for every binding, so N cross-chunk bindings sharing one source name cost O(N^2) lookups; the splitting/ManyCrossChunkExportAliasCollisions guard (20k such bindings) went from 0.5 s to 9.5 s in release and timed out on the macOS runners.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour. WalkthroughChangesCross-chunk name allocation
Merge Risk: ⚪ Minimal · up to This localized change improves naming performance for colliding cross-chunk bindings without changing generated output or program behavior; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the performance problem, the implementation change, measured improvements, regression test, verification results, and unchanged output. It does not use the template headings, but it contains the required information. Comment |
Follow-up to #40518.
assign_unminifiednumbered each cross-chunk binding by probingname2,name3, … from 2 every time, so N bindings with the same source name (e.g. 20k modules each exportingshared, imported across two entry points) cost O(N²) hash lookups. It now remembers the last suffix handed out per base name, asNumberScopedoes.test/bundler/bundler_splitting.test.ts›splitting/ManyCrossChunkExportAliasCollisions(20,000 colliding names, 15 s budget) is the guard: release x64 went 0.52 s (1.4.0) → 9.5 s (#40518) and it timed out / was marked flaky on macOS aarch64 in #40519's CI; debug build: >300 s → 11 s with this change. Output unchanged (same names, same program result).