Skip to content

bundler: fix quadratic naming of unminified cross-chunk bindings that share a source name - #40569

Merged
Jarred-Sumner merged 1 commit into
mainfrom
claude/cross-chunk-names-collision-perf
Aug 26, 2026
Merged

Jarred-Sumner merged 1 commit into
mainfrom
claude/cross-chunk-names-collision-perf

Conversation

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

Follow-up to #40518. assign_unminified numbered each cross-chunk binding by probing name2, name3, … from 2 every time, so N bindings with the same source name (e.g. 20k modules each exporting shared, imported across two entry points) cost O(N²) hash lookups. It now remembers the last suffix handed out per base name, as NumberScope does.

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).

…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.
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e360fbe3-72ba-4726-8050-80ac3bbd3af9

📥 Commits

Reviewing files that changed from the base of the PR and between 731aa92 and a875f01.

📒 Files selected for processing (1)
  • src/bundler/linker_context/crossChunkNames.rs

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.


Walkthrough

Changes

Cross-chunk name allocation

Layer / File(s) Summary
Reuse cached name suffixes
src/bundler/linker_context/crossChunkNames.rs
assign_unminified caches the latest suffix for each base identifier and starts subsequent collision checks from that suffix. Name allocation remains collision-free.

Merge Risk: ⚪ Minimal · up to a875f

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)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the quadratic naming performance fix for unminified cross-chunk bindings that share a source name.
Description check ✅ Passed 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, …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

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 @coderabbitai help to get the list of available commands.

@Jarred-Sumner
Jarred-Sumner merged commit ca214f2 into main Aug 26, 2026
10 of 12 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the claude/cross-chunk-names-collision-perf branch August 26, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant