Skip to content

perf(windows): reduce fs::metadata calls when adding a watch - #987

Merged
JohnTitor merged 1 commit into
notify-rs:mainfrom
rolldown:windows-reduce-metadata-calls
Aug 20, 2026
Merged

perf(windows): reduce fs::metadata calls when adding a watch#987
JohnTitor merged 1 commit into
notify-rs:mainfrom
rolldown:windows-reduce-metadata-calls

Conversation

@shulaoda

Copy link
Copy Markdown
Contributor

Description

On Windows, watch_inner checks that the path is a file or a directory before sending the request to the watcher thread, and add_watch then performs the exact same check again, plus one more is_dir call to decide between file and directory watching. Each is_dir/is_file call is a separate fs::metadata syscall, so a single watch request ends up doing up to five of them.

This PR removes the duplicated client-side check and reuses one metadata result in add_watch, reducing it to a single call. This mainly matters for applications that watch many individual files. As a side effect, the error for a non-existent path now includes the path, since it is reported by the watcher thread.

Ported from the rolldown fork: rolldown/notify@d44e327.

Additional review notes

Part of the same effort as #980: upstreaming small changes from the rolldown fork.

Related Issues

None.

@JohnTitor JohnTitor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cool, thanks!

@JohnTitor
JohnTitor merged commit 130cd27 into notify-rs:main Aug 20, 2026
21 checks passed
@shulaoda
shulaoda deleted the windows-reduce-metadata-calls branch August 21, 2026 03:25
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.

2 participants