perf(rolldown): probe the name map once in ConflictResolver::resolve#9899
Merged
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
Merging this PR will not alter performance
Comparing Footnotes
|
IWANABETHATGUY
approved these changes
Jun 21, 2026
Member
Author
Merge activity
|
…9899) ## What `ConflictResolver::resolve` is the per-symbol deconfliction primitive (shared by `Renamer` and the cross-chunk export pass) — called once for every top-level symbol in every chunk. Its fast path (the common case where the bare name is free) hashed and walked the `used` map **twice** for the same key: ```rust if !self.used.contains_key(&base) && accept(&base, true) { self.used.insert(base.clone(), 0); // second hash + table walk of `base` return base; } ``` This replaces the `contains_key` + `insert` pair with a single `entry()` probe. Semantics are identical: - `Vacant` + accepted → the old fast path (write the slot we already located) - `Vacant` + vetoed → leave `base` unrecorded, start the suffix search at 1 - `Occupied` → jump past it using its stored counter The clone count is unchanged (the map must own the key either way); the win is **one fewer hash + table walk per symbol** on the hot path. ## Evidence (cargo-asm, release / fat-LTO) Measured on the inlined caller `Renamer::add_symbol_in_root_scope`: | | asm lines | `contains_key` | `insert` | |---|---|---|---| | before | 927 | 1 | 4 | | after | 783 | 0 | 3 | ## Verification - `ConflictResolver` unit tests (incl. the counter-jump / veto edge cases) pass - `topics/deconflict` integration snapshots pass **byte-identically** - clippy clean Companion of #9900, which applies the same single-probe pattern to the `canonical_names` dedup in `add_symbol_in_root_scope`. The two are independent (disjoint files) and can land in either order.
6bda7f7 to
0a2670e
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Jun 21, 2026
…er (#9900) ## What `Renamer::add_symbol_in_root_scope` runs once per top-level symbol. On the deconflict path it probed `canonical_names` **twice** for the same `canonical_ref`: - a `contains_key` dedup guard up front (to skip building/allocating the owned name when the ref was already assigned), and - an `insert` at the end. This fuses them into a single `entry()` probe — an `Occupied` slot is the no-op dedup (still skipping the allocation), the `Vacant` slot is written after `resolve`. Behaviour is identical. While here, the JSX-aware "original name" derivation (upper-case the first char when `module.preserve_jsx` is set) was a free function in `renamer.rs` that reached across the crate boundary to recombine three `rolldown_common` primitives for its single caller. It moves to `SymbolRefDb::original_name`, beside its sibling `canonical_name_for_or_original` and the `MustStartWithCapitalLetterForJSX` flag it depends on — which also lets the renamer drop a now-dead `canonical_name` local and the `SymbolRefFlags` import. ## Evidence (cargo-asm, release / fat-LTO) The two single-probe changes compound on the inlined `add_symbol_in_root_scope` (measured cumulatively): | | asm lines | `contains_key` | `RawTable::find` | `insert` | |---|---|---|---|---| | original | 927 | 1 | 1 | 4 | | + #9899 | 783 | 0 | — | 3 | | + this PR | 647 | 0 | 0 | 2 | This PR removes the second `canonical_names` probe (the `RawTable::find` dedup walk) and one more `insert`. ## Verification - `ConflictResolver` unit tests pass - `topics/deconflict` integration snapshots pass **byte-identically** - clippy clean (`rolldown` + `rolldown_common`) Companion of #9899; the two are independent (disjoint files) and can land in either order.
Merged
shulaoda
added a commit
that referenced
this pull request
Jun 24, 2026
## [1.1.3] - 2026-06-24 ### 🐛 Bug Fixes - `defer_drop` crashes the browser main thread (#9942) by @shulaoda - camel-case: correct camel case for nested values (#9933) by @kb019 - cli: display --help options in camelCase (#9941) by @IWANABETHATGUY - preserve used re-exports under preserveModules (#9122) (#9934) by @IWANABETHATGUY - watch: make close reentrant in event callbacks (#9904) by @hyf0 - git for windows treats symlink files as regular files (#9915) by @AliceLanniste - dev: cancel pending full reload on build error (#9903) by @h-a-n-a - chunking: pass plugin meta to codeSplitting groups name function (#9267) by @Kyujenius - dev: serve assets emitted during HMR/lazy compile (vite#22596) (#9815) by @h-a-n-a - release: dry-run step no longer publishes binding packages (#9866) by @Boshen ### 🚜 Refactor - rolldown_common: model ModuleId as a classified Path/Virtual/Bare enum (#9927) by @Boshen - remove unused LegacyModuleIdx (#9872) by @shulaoda - remove unused StmtInfos::get_namespace_stmt_info (#9870) by @shulaoda - remove unused Module::as_external_mut (#9871) by @shulaoda - remove unused EcmaAst::is_body_empty (#9869) by @shulaoda - drop dead is_css_module handling in resolve_dependencies (#9867) by @shulaoda - drop redundant with_commonjs on cjs source type (#9868) by @shulaoda ### 📚 Documentation - clarify on drafting PRs (#9952) by @h-a-n-a - update contribution guidelines (#9944) by @fubhy - note Rust crates don't follow semver in AGENTS.md (#9905) by @IWANABETHATGUY - add feedback form (#9159) by @TheAlexLichter ### ⚡ Performance - utils: avoid allocation in default_sanitize_file_name for clean names (#9928) by @Boshen - binding: box once-per-build futures before spawn_future (#9864) by @Boshen - utils: avoid wasted allocation in legitimize_identifier_name (#9926) by @Boshen - rolldown: fuse the canonical-name dedup and insert in the renamer (#9900) by @Boshen - rolldown: probe the name map once in ConflictResolver::resolve (#9899) by @Boshen - cut two heap allocations from wrapped ESM init finalize (#9901) by @Boshen - rolldown_plugin_vite_reporter: hoist invariant out_dir prefix out of reporter loop (#9873) by @shulaoda - drop throwaway Vec in wrapped esm init stmt (#9878) by @shulaoda - borrow owner_filename in build-import-analysis AddDeps (#9874) by @shulaoda ### 🧪 Testing - cover preserveModules named export via namespace re-export (#6010) (#9937) by @IWANABETHATGUY ### ⚙️ Miscellaneous Tasks - deps: update napi to v3.9.4 (#9954) by @shulaoda - reduce noise from CODEOWNERS for trival changes (#9953) by @h-a-n-a - deps: update mimalloc-safe to 0.1.64 (#9950) by @shulaoda - deps: update rollup submodule for tests to v4.62.2 (#9931) by @rolldown-guard[bot] - deps: test mimalloc-safe upstream-mimalloc switch in CI (#9930) by @shulaoda - rolldown_plugin_vite_build_import_analysis: remove unused v2 code path (#9917) by @shulaoda - rolldown_plugin_vite_manifest: remove unused is_enable_v2 code path (#9916) by @shulaoda - rolldown_plugin_vite_asset_import_meta_url: remove unexposed native vite plugin (#9896) by @shulaoda - rolldown_plugin_vite_asset: remove unexposed native vite plugin (#9895) by @shulaoda - rolldown_plugin_vite_css_post: remove unexposed native vite plugin (#9894) by @shulaoda - rolldown_plugin_vite_css: remove unexposed native vite plugin (#9893) by @shulaoda - rolldown_plugin_vite_html_inline_proxy: remove unexposed native vite plugin (#9892) by @shulaoda - rolldown_plugin_vite_html: remove unexposed native vite plugin (#9891) by @shulaoda - deps: update github actions (#9909) by @renovate[bot] - deps: update rust crate oxc_sourcemap to v8.0.2 (#9910) by @renovate[bot] - deps: update npm packages (#9912) by @renovate[bot] - deps: update github actions to v7 (#9913) by @renovate[bot] - deps: update rolldown-plugin-dts to ^0.26.0 (#9897) by @renovate[bot] - remove rolldown_filter_analyzer crate (#9865) by @Boshen ### ❤️ New Contributors * @fubhy made their first contribution in [#9944](#9944) Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
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
ConflictResolver::resolveis the per-symbol deconfliction primitive (shared byRenamerand the cross-chunk export pass) — called once for every top-level symbol in every chunk.Its fast path (the common case where the bare name is free) hashed and walked the
usedmap twice for the same key:This replaces the
contains_key+insertpair with a singleentry()probe. Semantics are identical:Vacant+ accepted → the old fast path (write the slot we already located)Vacant+ vetoed → leavebaseunrecorded, start the suffix search at 1Occupied→ jump past it using its stored counterThe clone count is unchanged (the map must own the key either way); the win is one fewer hash + table walk per symbol on the hot path.
Evidence (cargo-asm, release / fat-LTO)
Measured on the inlined caller
Renamer::add_symbol_in_root_scope:contains_keyinsertVerification
ConflictResolverunit tests (incl. the counter-jump / veto edge cases) passtopics/deconflictintegration snapshots pass byte-identicallyCompanion of #9900, which applies the same single-probe pattern to the
canonical_namesdedup inadd_symbol_in_root_scope. The two are independent (disjoint files) and can land in either order.