Skip to content

perf: use IndexBitSet to replace IndexVec<XXXIdx, bool> for module/stmt inclusion tracking#8503

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-01-perf_use_indexbitset_to_replace_indexvec_xxxidx_bool_for_module_stmt_inclusion_tracking
Mar 1, 2026
Merged

perf: use IndexBitSet to replace IndexVec<XXXIdx, bool> for module/stmt inclusion tracking#8503
graphite-app[bot] merged 1 commit intomainfrom
03-01-perf_use_indexbitset_to_replace_indexvec_xxxidx_bool_for_module_stmt_inclusion_tracking

Conversation

@IWANABETHATGUY
Copy link
Member

No description provided.

Copy link
Member Author


How to use the Graphite Merge Queue

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

@netlify
Copy link

netlify bot commented Mar 1, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 9bd75f2
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69a407409b83430008b72c7d

@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review March 1, 2026 08:34
Copilot AI review requested due to automatic review settings March 1, 2026 08:34
@IWANABETHATGUY IWANABETHATGUY force-pushed the 03-01-perf_use_indexbitset_to_replace_indexvec_xxxidx_bool_for_module_stmt_inclusion_tracking branch from a406fdb to b7fe881 Compare March 1, 2026 08:35
Copy link
Member

@hyf0 hyf0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done on implementing @sapphi-red.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves performance and memory usage by replacing several IndexVec<XXXIdx, bool> inclusion/visited trackers with a compact IndexBitSet, and updates call sites to use has_bit/set_bit.

Changes:

  • Add a Default impl for IndexBitSet.
  • Migrate module/statement inclusion tracking from IndexVec<..., bool> to IndexBitSet across link + generate stages.
  • Update downstream consumers (debug output, finalizers, symbol deconflict, code splitting) to query inclusion via has_bit.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/rolldown_utils/src/index_bitset.rs Adds Default for IndexBitSet.
crates/rolldown_common/src/module/normal_module.rs Switches tree-shaking debug view to read statement inclusion from IndexBitSet.
crates/rolldown/src/utils/chunk/deconflict_chunk_symbols.rs Uses has_bit for filtering included statements.
crates/rolldown/src/types/linking_metadata.rs Changes stmt_info_included field to IndexBitSet and updates included-info conversion helpers.
crates/rolldown/src/stages/link_stage/wrapping.rs Replaces visited-module tracking with IndexBitSet.
crates/rolldown/src/stages/link_stage/tree_shaking/include_statements.rs Replaces stmt/module inclusion vectors with IndexBitSet and updates inclusion logic.
crates/rolldown/src/stages/link_stage/patch_module_dependencies.rs Uses has_bit for included-statement filtering.
crates/rolldown/src/stages/generate_stage/manual_code_splitting.rs Uses IndexBitSet for module assignment tracking.
crates/rolldown/src/stages/generate_stage/compute_cross_chunk_links.rs Uses has_bit to gate work on included statements.
crates/rolldown/src/stages/generate_stage/code_splitting.rs Uses IndexBitSet for module assignment + stmt inclusion queries.
crates/rolldown/src/stages/generate_stage/chunk_optimizer.rs Updates optimizer signature/logic to use IndexBitSet module assignment.
crates/rolldown/src/module_finalizers/mod.rs Updates finalizer to check statement inclusion via has_bit.
crates/rolldown/src/module_finalizers/impl_visit_mut.rs Updates wrap-kind and symbol checks to use has_bit.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

Benchmarks Rust

  • target: main(bc1eff2)
  • pr: 03-01-perf_use_indexbitset_to_replace_indexvec_xxxidx_bool_for_module_stmt_inclusion_tracking(9bd75f2)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     77.0±1.76ms        ? ?/sec    1.03     79.3±1.99ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     84.6±1.85ms        ? ?/sec    1.03     87.1±1.37ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    156.7±3.48ms        ? ?/sec    1.01    158.3±5.41ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    173.2±2.60ms        ? ?/sec    1.03    177.8±4.12ms        ? ?/sec
bundle/bundle@threejs                                        1.01     72.0±3.19ms        ? ?/sec    1.00     71.6±2.22ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     77.9±1.22ms        ? ?/sec    1.01     78.9±1.72ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    752.8±6.27ms        ? ?/sec    1.01    756.6±6.24ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    866.8±9.91ms        ? ?/sec    1.00    864.4±7.45ms        ? ?/sec
scan/scan@rome_ts                                            1.00     76.0±1.45ms        ? ?/sec    1.02     77.5±1.57ms        ? ?/sec
scan/scan@threejs                                            1.00     26.7±0.36ms        ? ?/sec    1.04     27.7±1.79ms        ? ?/sec
scan/scan@threejs10x                                         1.00    262.9±3.97ms        ? ?/sec    1.00    264.0±4.01ms        ? ?/sec

@IWANABETHATGUY IWANABETHATGUY force-pushed the 03-01-perf_use_indexbitset_to_replace_indexvec_xxxidx_bool_for_module_stmt_inclusion_tracking branch from b7fe881 to 8513dad Compare March 1, 2026 09:19
@graphite-app
Copy link
Contributor

graphite-app bot commented Mar 1, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the 03-01-perf_use_indexbitset_to_replace_indexvec_xxxidx_bool_for_module_stmt_inclusion_tracking branch from 8513dad to 9bd75f2 Compare March 1, 2026 09:30
@graphite-app graphite-app bot merged commit 9bd75f2 into main Mar 1, 2026
35 checks passed
@graphite-app graphite-app bot deleted the 03-01-perf_use_indexbitset_to_replace_indexvec_xxxidx_bool_for_module_stmt_inclusion_tracking branch March 1, 2026 09:42
This was referenced Mar 4, 2026
shulaoda added a commit that referenced this pull request Mar 5, 2026
## [1.0.0-rc.7] - 2026-03-05

⚡ Smarter Code Generation Defaults
- DCE-only minification and smart constant inlining are now enabled by default
- Produces cleaner, smaller output bundles without requiring explicit configuration

💡 LLM-Friendly Bundle Analyzer Reports
- New markdown output format for the bundle analyzer plugin with bundle summaries, module graphs, dependency chains, and optimization suggestions
- Optimization suggestions now also recommend using the entriesAware option when common chunks contain modules only reachable from specific entries


### 💥 BREAKING CHANGES

- enable minify: 'dce-only' by default (#8465) by @IWANABETHATGUY
- settings `inlineConst: { mode: 'smart', pass: 1}`  by default (#8444) by @IWANABETHATGUY

### 🚀 Features

- binding: add original getter to BindingMagicString (#8533) by @IWANABETHATGUY
- native-magic-string: add `offset` property support (#8531) by @IWANABETHATGUY
- add `output.strict` option to control `"use strict"` directive emission (#8489) by @Copilot
- watch: expose `watcher.compareContentsForPolling` (#8526) by @hyf0
- watch: use new watcher to support watch mode (#8475) by @hyf0
- rust/watch: handle bulk-change (#8466) by @hyf0
- add LLM-friendly markdown output format to bundle analyzer plugin (#8242) by @IWANABETHATGUY

### 🐛 Bug Fixes

- expose `plugins` on `NormalizedInputOptions` for `buildStart` hook (#8521) by @Copilot
- only uppercase facade symbols in JSX preserve mode (#8519) by @IWANABETHATGUY
- binding: export BindingResult in generated dts header (#8537) by @minsoo-web
- pre-resolve paths option to avoid `invoke_sync` deadlock (#8518) by @IWANABETHATGUY
- remove debug-only jsx_preset and UntranspiledSyntaxError (#8511) by @IWANABETHATGUY
- apply `topLevelVar` to exported `const`/`let` declarations (#8507) by @IWANABETHATGUY
- rolldown_plugin_vite_web_worker_post: avoid replacing `new.target` (#8488) by @sapphi-red
- update copyright year to 2026 (#8486) by @maciekzygmunt

### 🚜 Refactor

- rust: use Oxc's SymbolFlags::ConstVariable instead of custom IsConst flag (#8543) by @Dunqing
- rust: remove FacadeScoping, use Scoping::create_symbol for facade symbols (#8540) by @Dunqing
- rust/watch: remove hacky `reset_closed_for_watch_mode` (#8530) by @hyf0
- binding: return &str instead of String in filename() getter (#8534) by @IWANABETHATGUY
- rust: remove old watch mode implementation (#8525) by @hyf0
- rust/watch: simply watch logic in the binding layer (#8516) by @hyf0
- rust/watch: tweak struct/function names (#8464) by @hyf0

### 📚 Documentation

- explain how external modules work in rolldown (#8457) by @sapphi-red
- add some diagrams using graphviz (#8499) by @sapphi-red
- use `vitepress-plugin-graphviz` (#8498) by @sapphi-red
- list s390x/ppc64le prebuilt binaries (#8495) by @crusty-voidzero
- fix error type for `RolldownBuild.generate` and others (#8490) by @sapphi-red

### ⚡ Performance

- string_wizard: reduce allocations and add ASCII fast paths (#8541) by @IWANABETHATGUY
- use IndexBitSet to replace IndexVec<XXXIdx, bool> for module/stmt inclusion tracking (#8503) by @IWANABETHATGUY
- plugin: use IndexBitSet to optimize skipped plugins checking (#8497) by @ShroXd
- rust/tla: skip compute_tla if there is no module use TLA (#8487) by @ShroXd

### 🧪 Testing

- node/watch: make watch tests run in concurrent and retry-able (#8512) by @hyf0
- add test case for static flag tree-shaking (#8476) by @IWANABETHATGUY
- migrate post-banner sourcemap-with-shebang to Rust (#8477) by @Copilot

### ⚙️ Miscellaneous Tasks

- vscode: `formatOnSave` for markdown files using oxc formatter (#8536) by @minsoo-web
- deps: update test262 submodule for tests (#8528) by @sapphi-red
- remove `retry` workaround from output paths test fixtures (#8520) by @Copilot
- docs: add Shuyuan Wang (h-a-n-a) and remove from acknowledgements (#8509) by @Copilot
- consolidate top_level_var test cases using configVariants (#8508) by @IWANABETHATGUY
- add s390x and ppc64le linux gnu targets (#8493) by @Brooooooklyn

### ◀️ Revert

- fix(rolldown): increase tokio blocking threads size for watch mode (#8517) by @hyf0

### ❤️ New Contributors

* @minsoo-web made their first contribution in [#8536](#8536)
* @crusty-voidzero made their first contribution in [#8495](#8495)
* @maciekzygmunt made their first contribution in [#8486](#8486)

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
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.

3 participants