Skip to content

feat(rust/watch): handle bulk-change#8466

Merged
graphite-app[bot] merged 1 commit intomainfrom
02-26-feat_rust_watch_handle_bulk-change
Mar 1, 2026
Merged

feat(rust/watch): handle bulk-change#8466
graphite-app[bot] merged 1 commit intomainfrom
02-26-feat_rust_watch_handle_bulk-change

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Feb 25, 2026

No description provided.

Copy link
Member Author

hyf0 commented Feb 25, 2026

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 optimizes the watcher's bulk file change handling by replacing the O(n²) deduplication approach with an O(1) FxIndexMap-based solution. Previously, each file change triggered an individual state transition with vector-based deduplication; now batches of changes are processed together with a single state transition, significantly improving performance for scenarios like git checkout that generate thousands of file events.

Changes:

  • Replace Vec<FileChangeEvent> with FxIndexMap<String, WatcherChangeKind> for O(1) deduplication by path
  • Rename on_file_change to on_file_changes to accept batches of changes
  • Update state machine to perform a single state transition per batch instead of per-file transitions

Reviewed changes

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

File Description
meta/design/watch-mode.md Updated documentation to reflect completed bulk-change optimization and FxIndexMap usage
crates/rolldown_watcher/src/watcher_state.rs Refactored state machine to use FxIndexMap for change storage and batch processing
crates/rolldown_watcher/src/watch_coordinator.rs Updated coordinator to work with batched file changes and FxIndexMap
Comments suppressed due to low confidence (1)

crates/rolldown_watcher/src/watcher_state.rs:192

  • Consider adding test coverage for the edge case where on_file_changes is called with an empty Vec. This would verify the behavior when no file changes are provided, which relates to the potential issue where empty entries could cause unnecessary state transitions or timer resets.
  #[test]
  fn test_batch_deduplicates_within_single_call() {
    let state = WatcherState::Idle;
    let entries = vec![
      FileChangeEvent::new("test.js".into(), WatcherChangeKind::Create),
      FileChangeEvent::new("test.js".into(), WatcherChangeKind::Update),
    ];
    let state = state.on_file_changes(entries, default_duration());

    if let WatcherState::Debouncing { changes, .. } = state {
      assert_eq!(changes.len(), 1);
      assert_eq!(changes["test.js"], WatcherChangeKind::Update);
    } else {
      panic!("Expected Debouncing state");
    }
  }

@hyf0 hyf0 force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from 3ec5efa to 0960e6d Compare February 25, 2026 16:53
@hyf0 hyf0 requested a review from sapphi-red February 25, 2026 16:54
@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

Benchmarks Rust

  • target: main(b44f77d)
  • pr: 02-26-feat_rust_watch_handle_bulk-change(7a134b9)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     78.6±1.36ms        ? ?/sec    1.00     78.3±1.27ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     86.8±1.64ms        ? ?/sec    1.01     87.5±2.26ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    159.3±4.63ms        ? ?/sec    1.00    159.5±3.60ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    176.5±3.74ms        ? ?/sec    1.01    177.7±3.42ms        ? ?/sec
bundle/bundle@threejs                                        1.00     72.1±2.57ms        ? ?/sec    1.00     71.8±1.17ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     79.9±1.48ms        ? ?/sec    1.00     79.8±0.90ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    755.5±5.32ms        ? ?/sec    1.00    758.0±7.14ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    866.3±6.16ms        ? ?/sec    1.00    866.2±6.96ms        ? ?/sec
scan/scan@rome_ts                                            1.00     76.3±1.91ms        ? ?/sec    1.01     77.0±1.52ms        ? ?/sec
scan/scan@threejs                                            1.01     27.5±1.61ms        ? ?/sec    1.00     27.2±0.39ms        ? ?/sec
scan/scan@threejs10x                                         1.00    266.8±2.86ms        ? ?/sec    1.00    266.6±2.87ms        ? ?/sec

@graphite-app graphite-app bot force-pushed the 02-25-refactor_rust_watch_tweak_struct_function_names branch from a9713cd to fe06c42 Compare February 26, 2026 03:27
@graphite-app graphite-app bot force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from 0960e6d to 2284793 Compare February 26, 2026 03:27
@graphite-app graphite-app bot force-pushed the 02-25-refactor_rust_watch_tweak_struct_function_names branch 2 times, most recently from cd11c19 to 4ef73e1 Compare February 26, 2026 04:29
@graphite-app graphite-app bot force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from 2284793 to 9d5b697 Compare February 26, 2026 04:29
@hyf0 hyf0 force-pushed the 02-25-refactor_rust_watch_tweak_struct_function_names branch from 4ef73e1 to d9b1ab3 Compare February 26, 2026 13:31
@hyf0 hyf0 force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from 9d5b697 to 0a8803f Compare February 26, 2026 13:31
@hyf0 hyf0 force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from 0a8803f to 893b0d1 Compare March 1, 2026 08:57
@hyf0 hyf0 force-pushed the 02-25-refactor_rust_watch_tweak_struct_function_names branch from d9b1ab3 to 850f783 Compare March 1, 2026 08:57
@hyf0 hyf0 force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from 893b0d1 to 26f0e94 Compare March 1, 2026 10:52
@graphite-app graphite-app bot changed the base branch from 02-25-refactor_rust_watch_tweak_struct_function_names to graphite-base/8466 March 1, 2026 11:03
@hyf0 hyf0 force-pushed the graphite-base/8466 branch from 850f783 to f62ae0f Compare March 1, 2026 12:10
@hyf0 hyf0 force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from 26f0e94 to a34f94f Compare March 1, 2026 12:10
@hyf0 hyf0 changed the base branch from graphite-base/8466 to main March 1, 2026 12:10
Copilot AI review requested due to automatic review settings March 1, 2026 12:26
@hyf0 hyf0 force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from a34f94f to f8229f5 Compare March 1, 2026 12:26
@netlify
Copy link

netlify bot commented Mar 1, 2026

Deploy Preview for rolldown-rs canceled.

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

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

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

@hyf0 hyf0 force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from f8229f5 to 7a134b9 Compare March 1, 2026 13:01
Copilot AI review requested due to automatic review settings March 1, 2026 16:17
@hyf0 hyf0 force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from 7a134b9 to 4ce9c30 Compare March 1, 2026 16:17
Copy link
Member Author

hyf0 commented Mar 1, 2026

Merge activity

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@graphite-app graphite-app bot force-pushed the 02-26-feat_rust_watch_handle_bulk-change branch from 4ce9c30 to 6e2d82f Compare March 1, 2026 16:29
@graphite-app graphite-app bot merged commit 6e2d82f into main Mar 1, 2026
34 checks passed
@graphite-app graphite-app bot deleted the 02-26-feat_rust_watch_handle_bulk-change branch March 1, 2026 16:39
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.

4 participants