perf(rolldown): some minor perf optimization found by autoresearch#8730
perf(rolldown): some minor perf optimization found by autoresearch#8730graphite-app[bot] merged 1 commit intomainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
✅ Deploy Preview for rolldown-rs canceled.
|
How to use the Graphite Merge QueueAdd the label graphite: merge-when-ready to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR targets minor performance optimizations in rolldown_sourcemap’s collapse_sourcemaps implementation by removing hash-map based source ID remapping and introducing parallel processing over tokens, along with dropping the direct rustc-hash dependency from this crate.
Changes:
- Parallelize token processing in
collapse_sourcemapsusingrolldown_utils::rayon. - Simplify source ID handling by using
original_token.get_source_id()directly (removing source-index remapping/caching). - Remove
rustc-hashfromcrates/rolldown_sourcemapdependencies (and updateCargo.lock).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/rolldown_sourcemap/src/lib.rs | Switches collapse_sourcemaps token traversal to rayon and removes source-id remapping logic. |
| crates/rolldown_sourcemap/Cargo.toml | Drops rustc-hash dependency for this crate. |
| Cargo.lock | Updates lockfile to reflect removed dependency. |
0e2508f to
2e6a386
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
2e6a386 to
6b669f1
Compare
There was a problem hiding this comment.
Pull request overview
This PR targets small performance improvements in rolldown by optimizing sourcemap collapsing and adjusting a JSX parsing flag used during chunk minification.
Changes:
- Parallelize token processing in
rolldown_sourcemap::collapse_sourcemapsand removerustc-hashusage fromrolldown_sourcemap. - Optimize newline counting in
rolldown_sourcemapwithmemchr_iter. - Make minify-stage JSX parsing conditional on
transform_options.is_jsx_preserve().
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rolldown_sourcemap/src/source.rs | Switch newline counting to memchr_iter for simpler/faster scanning. |
| crates/rolldown_sourcemap/src/lib.rs | Parallelize collapse token mapping and remove hash-based source-id remapping/cache. |
| crates/rolldown_sourcemap/Cargo.toml | Drop rustc-hash dependency from rolldown_sourcemap. |
| crates/rolldown/src/stages/generate_stage/minify_chunks.rs | Make JSX parsing toggle depend on is_jsx_preserve(). |
| Cargo.lock | Remove rustc-hash from the resolved dependency set for rolldown_sourcemap. |
Comments suppressed due to low confidence (1)
crates/rolldown_sourcemap/src/lib.rs:90
par_bridge()produces an unindexedParallelIterator, so the subsequentcollect::<Vec<_>>()does not guarantee preserving the original token order. Sourcemap token ordering is typically required to be sorted by (dst_line, dst_col) for correct lookup/serialization and for deterministic output; collecting in parallel here can silently scramble ordering. Consider switching to an indexed parallel iterator (e.g. collect tokens first theninto_par_iter()), or sort the resultingtokensby destination position before constructing theSourceMap.
let tokens = last_map
.get_source_view_tokens()
.par_bridge()
.filter_map(|token| {
let original_token = sourcemap_and_lookup_table.iter().rev().try_fold(
token,
|token, (sourcemap, lookup_table)| {
sourcemap.lookup_source_view_token(
lookup_table,
token.get_src_line(),
token.get_src_col(),
)
},
);
original_token.map(|original_token| {
Token::new(
token.get_dst_line(),
token.get_dst_col(),
original_token.get_src_line(),
original_token.get_src_col(),
original_token.get_source_id(),
original_token.get_name_id(),
)
})
})
.collect::<Vec<_>>();
a91449a to
7dc38dd
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to improve build performance by streamlining sourcemap collapsing and reducing unnecessary work during minification (notably around line counting and JSX parsing mode selection).
Changes:
- Optimizes newline counting in
SourceMapSourceby switching tomemchr_iter. - Simplifies
collapse_sourcemapsby removingrustc-hash-based source remapping/cache and directly forwarding source/name IDs from the folded token. - Adjusts chunk minification to enable JSX parsing only when
transform_options.is_jsx_preserve()is set, and removesrustc-hashfromrolldown_sourcemapdependencies.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rolldown_sourcemap/src/source.rs | Uses memchr_iter for faster newline counting. |
| crates/rolldown_sourcemap/src/lib.rs | Removes FxHashMap remapping/cache in collapse_sourcemaps; forwards source_id directly. |
| crates/rolldown_sourcemap/Cargo.toml | Drops rustc-hash dependency from the sourcemap crate. |
| crates/rolldown/src/stages/generate_stage/minify_chunks.rs | Makes JSX parsing in minifier conditional on is_jsx_preserve(). |
| Cargo.lock | Updates lockfile to reflect removed rustc-hash dependency. |
Comments suppressed due to low confidence (1)
crates/rolldown_sourcemap/src/lib.rs:88
- The PR description mentions collapsing sourcemaps by processing tokens in parallel and re-sorting tokens for deterministic output. In the current implementation here, tokens are processed sequentially via
get_source_view_tokens().filter_map(...).collect::<Vec<_>>()and there is no explicit re-sort step. If the description is meant to reflect the final behavior, either update the implementation or adjust the PR description to match what’s actually shipped.
let tokens = last_map
.get_source_view_tokens()
.filter_map(|token| {
let original_token = sourcemap_and_lookup_table.iter().rev().try_fold(
token,
|token, (sourcemap, lookup_table)| {
sourcemap.lookup_source_view_token(
lookup_table,
token.get_src_line(),
token.get_src_col(),
)
},
);
original_token.map(|original_token| {
Token::new(
token.get_dst_line(),
token.get_dst_col(),
original_token.get_src_line(),
original_token.get_src_col(),
original_token.get_source_id(),
original_token.get_name_id(),
)
})
})
.collect::<Vec<_>>();
Benchmarks Rust |
Merging this PR will not alter performance
Comparing Footnotes
|
4444d38 to
56cddc8
Compare
Merge activity
|
…8730) <!-- CURSOR_SUMMARY --> > [!NOTE] > **Medium Risk** > Touches `collapse_sourcemaps`, which is used in chunk rendering/minification; incorrect `source_id` propagation could subtly break sourcemap fidelity even though the change is small and performance-motivated. > > **Overview** > **Optimizes sourcemap processing** by removing `rustc-hash`/`rolldown_utils` dependencies and simplifying `collapse_sourcemaps` to pass through `source_id` directly instead of remapping via cached hash maps. > > Also swaps newline counting in `SourceMapSource` to use `memchr::memchr_iter` for faster `\n` scanning. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 56cddc8. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
56cddc8 to
308427e
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
## [1.0.0-rc.10] - 2026-03-18 ### 🚀 Features - add indentExclusionRanges property to MagicString (#8746) by @IWANABETHATGUY - expose `oxcRuntimePlugin` (#8654) by @sapphi-red - rust: make bundler generic over FileSystem for in-memory benchmarks (#8652) by @Boshen ### 🐛 Bug Fixes - rolldown_plugin_vite_dynamic_import_vars: align dynamic import fast check with Vite (#8760) by @shulaoda - renamer: handle existing bindings in nested scopes when finding unique names (#8741) by @drewolson - pass `yarn_pnp` option where needed (#8736) by @sapphi-red - preserve optional chaining in namespace member expr rewrite (#8712) by @Copilot - correct UTF-16 index handling in native MagicString (#8693) by @IWANABETHATGUY - mark failing doctests as ignore (#8700) by @Boshen - prevent may_partial_namespace from leaking through include_module (#8682) by @IWANABETHATGUY - ci: bump native-build cache key to invalidate stale napi-rs artifacts (#8678) by @Boshen - `comments.annotation: false` breaking tree-shaking (#8657) by @IWANABETHATGUY - validate filenames for NUL bytes from chunkFileNames/entryFileNames (#8644) by @IWANABETHATGUY - dce-only minify should not set NODE_ENV to production (#8651) by @IWANABETHATGUY ### 🚜 Refactor - rust: remove dead `CrossModuleOptimizationConfig::side_effects_free_function_optimization` (#8673) by @Dunqing - rust: simplify `cross_module_optimization` by removing redundant scope tracking (#8672) by @Dunqing - simplify string repeat in guess_indentor (#8753) by @IWANABETHATGUY - consolidate custom magic-string tests into one file (#8696) by @IWANABETHATGUY - extract CJS bailout checks from include_symbol (#8683) by @IWANABETHATGUY - rust: remove `BindingIdentifierExt` to use `BindingIdentifier::symbol_id()` instead (#8667) by @Dunqing - bench: add bench_preset helper and inline presets (#8658) by @Boshen - rust: filter external modules from entries instead of mapping bit positions (#8637) by @Dunqing ### 📚 Documentation - clarify watch mode behavior and its limitations (#8751) by @sapphi-red - add external link icon to GitHub button in Hero section (#8731) by @thisisnkc - guide: clarify that `inject` option is only conceptually similar to esbuild's one (#8743) by @sapphi-red - meta/design: add `devtools.md` (#8663) by @hyf0 - add viteplus alpha announcement banner (#8668) by @shulaoda ### ⚡ Performance - rolldown: some minor perf optimization found by autoresearch (#8730) by @Brooooooklyn - replace Vec allocation with lazy iterator in find_hash_placeholders (#8703) by @Boshen - replace TypedDashMap with TypedMap in CustomField (#8708) by @Boshen - bench: remove scan benchmark binary to halve LTO link time (#8694) by @Boshen ### 🧪 Testing - watch: increase timeout for error output (#8766) by @sapphi-red - vite-tests: remove JS plugin tests (#8767) by @sapphi-red - watch: add CLI exit code test (#8752) by @sapphi-red - normalize paths on Windows even if `resolve.symlinks` is false (#8483) by @sapphi-red ### ⚙️ Miscellaneous Tasks - correct comment in bundle-analyzer-plugin.ts (#8770) by @origami-z - upgrade oxc to 0.120.0 (#8764) by @Boshen - enable all test for `reset` category in MagicString.test.ts (#8749) by @IWANABETHATGUY - deps: update test262 submodule for tests (#8742) by @sapphi-red - deps: update oxc apps (#8734) by @renovate[bot] - deps: update softprops/action-gh-release action to v2.6.1 (#8724) by @renovate[bot] - deps: update npm packages (major) (#8722) by @renovate[bot] - deps: update github-actions (major) (#8721) by @renovate[bot] - deps: update softprops/action-gh-release action to v2.6.0 (#8720) by @renovate[bot] - deps: update npm packages (#8718) by @renovate[bot] - deps: update rust crates (#8717) by @renovate[bot] - deps: update github-actions (#8716) by @renovate[bot] - deps: update dependency oxlint-tsgolint to v0.17.0 (#8713) by @renovate[bot] - deps: bump cargo-shear to v1.11.2 (#8711) by @Boshen - use org level `CODE_OF_CONDUCT.md` (#8706) by @sapphi-red - fix cache key mismatch and remove redundant cache saves (#8695) by @Boshen - deps: update oxc apps (#8692) by @renovate[bot] - deps: update oxc apps (#8649) by @renovate[bot] - should do matrix out side of reusable workflows 2 (#8691) by @hyf0 - should do matrix out side of reusable workflows (#8690) by @hyf0 - deps: update dependency rolldown-plugin-dts to v0.22.5 (#8689) by @renovate[bot] - upgrade oxc to 0.119.0 and oxc_resolver to 11.19.1 (#8686) by @Boshen - correct if condition of `type-check` job (#8677) by @hyf0 - Gate CI type-check job on node changes (#8669) by @Copilot - benchmark: improve codspeed build (#8665) by @Boshen - deps: update oxc to v0.118.0 (#8650) by @renovate[bot] - deps: update crate-ci/typos action to v1.44.0 (#8647) by @renovate[bot] - deps: update oxc resolver to v11.19.1 (#8646) by @renovate[bot] - deps: update dependency rust to v1.94.0 (#8648) by @renovate[bot] - deps: update dependency rolldown-plugin-dts to v0.22.4 (#8645) by @renovate[bot] ###◀️ Revert - Revert "ci: Gate CI type-check job on node changes" (#8674) by @hyf0 - "chore(deps): update dependency rust to v1.94.0 (#8648)" (#8660) by @shulaoda ### ❤️ New Contributors * @origami-z made their first contribution in [#8770](#8770) * @drewolson made their first contribution in [#8741](#8741) * @thisisnkc made their first contribution in [#8731](#8731) Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>



Note
Medium Risk
Touches
collapse_sourcemaps, which is used in chunk rendering/minification; incorrectsource_idpropagation could subtly break sourcemap fidelity even though the change is small and performance-motivated.Overview
Optimizes sourcemap processing by removing
rustc-hash/rolldown_utilsdependencies and simplifyingcollapse_sourcemapsto pass throughsource_iddirectly instead of remapping via cached hash maps.Also swaps newline counting in
SourceMapSourceto usememchr::memchr_iterfor faster\nscanning.Written by Cursor Bugbot for commit 56cddc8. This will update automatically on new commits. Configure here.