Skip to content

Comments

perf: reuse the same ReadDirectoryChangesW handle for watching a file in the same directory#3

Merged
sapphi-red merged 2 commits intomainfrom
11-13-perf_reuse_the_same_readdirectorychangesw_handle_for_watching_a_file_in_the_same_directory
Nov 13, 2025
Merged

perf: reuse the same ReadDirectoryChangesW handle for watching a file in the same directory#3
sapphi-red merged 2 commits intomainfrom
11-13-perf_reuse_the_same_readdirectorychangesw_handle_for_watching_a_file_in_the_same_directory

Conversation

@sapphi-red
Copy link
Member

Reuse the handle to reduce the number of handles.
For the paths_mut bench which has many files in the same directory, it improves the perf by 30% - 40%.

windows_paths_mut/nonrecursive/100
                        time:   [3.1044 ms 3.1738 ms 3.2479 ms]
                        change: [−30.776% −28.596% −26.358%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high mild
windows_paths_mut/recursive/100
                        time:   [2.8929 ms 2.9234 ms 2.9591 ms]
                        change: [−38.235% −36.313% −34.358%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  5 (5.00%) high mild
  6 (6.00%) high severe
windows_paths_mut/nonrecursive/500
                        time:   [14.293 ms 14.573 ms 14.863 ms]
                        change: [−36.807% −34.687% −32.563%] (p = 0.00 < 0.05)
                        Performance has improved.
windows_paths_mut/recursive/500
                        time:   [14.296 ms 14.590 ms 14.904 ms]
                        change: [−40.632% −38.698% −36.666%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high mild
windows_paths_mut/nonrecursive/1000
                        time:   [28.555 ms 29.174 ms 29.850 ms]
                        change: [−43.973% −42.293% −40.487%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high mild
windows_paths_mut/recursive/1000
                        time:   [28.275 ms 28.829 ms 29.409 ms]
                        change: [−42.775% −40.867% −38.956%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild

@sapphi-red sapphi-red merged commit 91dd20a into main Nov 13, 2025
6 checks passed
@sapphi-red sapphi-red deleted the 11-13-perf_reuse_the_same_readdirectorychangesw_handle_for_watching_a_file_in_the_same_directory branch November 13, 2025 14:19
@Boshen Boshen mentioned this pull request Nov 16, 2025
Boshen added a commit that referenced this pull request Nov 16, 2025
## 🤖 New release

* `rolldown-notify-types`: 2.0.0 -> 2.0.1 (✓ API compatible changes)
* `rolldown-notify`: 8.2.0 -> 8.2.1 (✓ API compatible changes)
* `rolldown-file-id`: 0.2.3 -> 0.2.4 (✓ API compatible changes)
* `rolldown-notify-debouncer-full`: 0.6.0 -> 0.6.1 (✓ API compatible
changes)
* `rolldown-notify-debouncer-mini`: 0.7.0 -> 0.7.1

<details><summary><i><b>Changelog</b></i></summary><p>

## `rolldown-notify-types`

<blockquote>

##
[2.0.1](rolldown-notify-types-v2.0.0...rolldown-notify-types-v2.0.1)
- 2025-11-16

### Other

- update rust toolchain to 1.90.0
</blockquote>

## `rolldown-notify`

<blockquote>

##
[8.2.1](rolldown-notify-v8.2.0...rolldown-notify-v8.2.1)
- 2025-11-16

### Fixed

- emit `remove` event if add watch fails due to non-existing path for
kqueue watcher ([#6](#6))
- throw fsevents stream start error properly
([#4](#4))

### Other

- add kqueue tests ([#5](#5))
- reuse the same `ReadDirectoryChangesW` handle for watching a file in
the same directory ([#3](#3))
- migrate to rust edition 2024
([#2](#2))
- add benchmark for .paths_mut
([#1](#1))
- fix test failure with macOS kqueue
- add test helpers and tests
([notify-rs#728](https://github.com/rolldown/notify/pull/728))
- `FsEventWatcher` crashes when dealing with empty path
([notify-rs#718](https://github.com/rolldown/notify/pull/718))
- update rust toolchain to 1.90.0
</blockquote>

## `rolldown-file-id`

<blockquote>

##
[0.2.4](rolldown-file-id-v0.2.3...rolldown-file-id-v0.2.4)
- 2025-11-16

### Other

- migrate to rust edition 2024
([#2](#2))
</blockquote>

## `rolldown-notify-debouncer-full`

<blockquote>

##
[0.6.1](rolldown-notify-debouncer-full-v0.6.0...rolldown-notify-debouncer-full-v0.6.1)
- 2025-11-16

### Other

- migrate to rust edition 2024
([#2](#2))
</blockquote>

## `rolldown-notify-debouncer-mini`

<blockquote>

##
[0.7.1](rolldown-notify-debouncer-mini-v0.7.0...rolldown-notify-debouncer-mini-v0.7.1)
- 2025-11-16

### Other

- updated the following local packages: rolldown-notify-types,
rolldown-notify
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
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.

1 participant