Skip to content

feat(rust): make bundler generic over FileSystem for in-memory benchmarks#8652

Merged
Boshen merged 11 commits intomainfrom
feat/memory-fs-benchmarks
Mar 12, 2026
Merged

feat(rust): make bundler generic over FileSystem for in-memory benchmarks#8652
Boshen merged 11 commits intomainfrom
feat/memory-fs-benchmarks

Conversation

@Boshen
Copy link
Copy Markdown
Member

@Boshen Boshen commented Mar 12, 2026

Summary

  • Propagate Fs: FileSystem type parameter through the bundler pipeline (TaskContextModuleLoaderScanStageBundle) so benchmarks can inject a MemoryFileSystem, eliminating disk I/O noise from measurements
  • Add BundleFactory::create_bundle_with_fs() for injecting custom FS/resolver pairs
  • Update benchmarks to preload source files into MemoryFileSystem outside the timed loop

The public API (Bundler, BundlerBuilder) remains unchanged — all generic structs use = OsFileSystem defaults.

Closes #8642

🤖 Generated with Claude Code

…arks

Propagate the `Fs: FileSystem` type parameter through the bundler pipeline
(TaskContext, ModuleLoader, ScanStage, Bundle) so benchmarks can inject a
MemoryFileSystem, eliminating disk I/O noise from measurements. The public
API (Bundler, BundlerBuilder) remains unchanged with OsFileSystem defaults.

Closes #8642

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 12, 2026

Deploy Preview for rolldown-rs canceled.

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

autofix-ci bot and others added 4 commits March 12, 2026 08:44
…t of timed loop

- Extract `build_bundle` helper in BundleFactory to deduplicate create_bundle/create_bundle_with_fs
- Move BundleFactory::new() outside benchmark iteration loop (was inflating measurements)
- Introduce BenchContext to consolidate one-time benchmark setup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ith_fs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Boshen Boshen marked this pull request as ready for review March 12, 2026 09:37
@Boshen Boshen requested review from Copilot and hyf0 March 12, 2026 09:37
Copy link
Copy Markdown
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 generalizes rolldown’s core pipeline to support pluggable filesystem backends (via rolldown_fs::FileSystem) and updates the benchmark harness to preload fixture projects into an in-memory filesystem to reduce disk I/O during timed benchmark runs.

Changes:

  • Thread Fs: FileSystem generics through scanning/module-loading/HMR/bundling paths (defaulting to OsFileSystem).
  • Make SharedResolver generic over the filesystem backend (Resolver<Fs>).
  • Update benchmarks to build bundles using MemoryFileSystem + a custom Resolver<MemoryFileSystem>, plus add helpers to preload directories into memory.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/rolldown/src/utils/load_entry_module.rs Make entry loading accept a resolver backed by an arbitrary FileSystem.
crates/rolldown/src/stages/scan_stage.rs Parameterize ScanStage over Fs and use SharedResolver<Fs>.
crates/rolldown/src/module_loader/task_context.rs Make TaskContext generic over Fs for shared module-loader state.
crates/rolldown/src/module_loader/runtime_module_task.rs Thread Fs through runtime-module loading task context.
crates/rolldown/src/module_loader/resolve_utils.rs Make resolver helpers generic over Fs: FileSystem.
crates/rolldown/src/module_loader/module_task.rs Parameterize ModuleTask over Fs to match generic task context.
crates/rolldown/src/module_loader/module_loader.rs Parameterize ModuleLoader over Fs and pass Fs/Resolver<Fs> through.
crates/rolldown/src/module_loader/external_module_task.rs Parameterize external-module task over Fs-backed task context.
crates/rolldown/src/lib.rs Change SharedResolver alias to SharedResolver<Fs> = Arc<Resolver<Fs>>.
crates/rolldown/src/hmr/hmr_stage.rs Parameterize HMR stage input/stage over Fs + SharedResolver<Fs>.
crates/rolldown/src/bundle/bundle.rs Parameterize Bundle over Fs to support non-OS builds.
crates/rolldown/src/bundle/bundle_factory.rs Add create_bundle_with_fs and refactor bundle creation to accept custom Fs/resolver.
crates/rolldown_plugin/src/utils/resolve_id_with_plugins.rs Make plugin resolve helpers accept Resolver<Fs>.
crates/rolldown_plugin/src/utils/resolve_id_check_external.rs Make external-check resolve helper accept Resolver<Fs>.
crates/rolldown_plugin/Cargo.toml Add rolldown_fs dependency for the new FileSystem bound.
crates/bench/src/lib.rs Add helpers to preload a directory into MemoryFileSystem and build a reusable bench context.
crates/bench/Cargo.toml Add dependencies on rolldown_fs (memory) and rolldown_resolver.
crates/bench/benches/scan.rs Update scan benchmark to use preloaded MemoryFileSystem bundles per iteration.
crates/bench/benches/bundle.rs Update bundle benchmark to use preloaded MemoryFileSystem bundles per iteration.
Cargo.lock Record new workspace dependency edges for bench/plugin changes.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7591c8ed39

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 12, 2026

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing feat/memory-fs-benchmarks (c789186) with main (9710def)

Open in CodSpeed

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 12, 2026

Benchmarks Rust

group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     65.1±1.38ms        ? ?/sec    1.16     75.7±1.68ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     74.2±1.67ms        ? ?/sec    1.14     84.4±2.27ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    142.1±2.64ms        ? ?/sec    1.11    157.4±2.29ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    162.4±2.56ms        ? ?/sec    1.08    174.7±2.60ms        ? ?/sec
bundle/bundle@threejs                                        1.00     61.4±1.98ms        ? ?/sec    1.15     70.5±2.63ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     71.5±1.37ms        ? ?/sec    1.08     77.3±0.88ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    717.5±5.54ms        ? ?/sec    1.07    767.4±6.17ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    825.6±5.55ms        ? ?/sec    1.07    879.8±6.76ms        ? ?/sec
scan/scan@rome_ts                                            1.00     67.8±1.19ms        ? ?/sec    1.15     77.9±1.47ms        ? ?/sec
scan/scan@threejs                                            1.00     24.3±1.35ms        ? ?/sec    1.13     27.4±0.52ms        ? ?/sec
scan/scan@threejs10x                                         1.00    241.2±4.25ms        ? ?/sec    1.11    267.7±3.61ms        ? ?/sec

Boshen and others added 2 commits March 12, 2026 18:52
- Remove `= OsFileSystem` defaults from internal types, keeping defaults only on public API types (Bundle, Resolver)
- Fix tsconfig handling in bench: use `options.tsconfig.with_base(&cwd)` instead of `Default::default()`
- Create fresh resolver per benchmark iteration to avoid cache warming bias

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 12, 2026 10:53
@Boshen Boshen review requested due to automatic review settings March 12, 2026 10:53
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c6f818bbc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

… bundler pipeline

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 12, 2026 11:53
Copy link
Copy Markdown
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

Copilot reviewed 20 out of 21 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b6ea29d608

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Boshen and others added 2 commits March 12, 2026 21:29
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 12, 2026 13:39
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6284686b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
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

Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

@Boshen Boshen merged commit 91ca4ea into main Mar 12, 2026
38 checks passed
@Boshen Boshen deleted the feat/memory-fs-benchmarks branch March 12, 2026 14:05
This was referenced Mar 18, 2026
shulaoda added a commit that referenced this pull request Mar 18, 2026
## [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>
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.

Rework CI benchmark suite for per-stage granularity and I/O elimination

3 participants