Skip to content

fs: Polling backend support - #54481

Merged
kubkon merged 7 commits into
mainfrom
feat-fs-poll-watching
Apr 23, 2026
Merged

fs: Polling backend support#54481
kubkon merged 7 commits into
mainfrom
feat-fs-poll-watching

Conversation

@probably-neb

@probably-neb probably-neb commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #51340
Release Notes:

  • Linux/WSL: Added polling filesystem watching support in order to support file watching on file systems that do emit events through inotify, for example /mnt/c in WSL, network filesystems, and FUSE mounts. Polling should be automatically chosen over inotify when necessary, however it can be manually chosen by setting the ZED_FILE_WATCHER_MODE=poll env var

lilith and others added 5 commits April 20, 2026 16:14
Auto-detect filesystems where inotify silently fails to deliver events
(9P/drvfs on WSL2, NFS, CIFS/SMB, FUSE/sshfs) and use notify's
PollWatcher instead of the native INotifyWatcher.

Detection uses libc::statfs to check filesystem magic numbers, plus
a WSL drvfs path heuristic as fallback.

Environment variable overrides:
- ZED_FILE_WATCHER_MODE=poll|native|auto (default: auto)
- ZED_FILE_WATCHER_POLL_MS=2000 (range: 500-30000)

No trait changes, no settings changes — pure auto-detection with
env var escape hatches. Settings UI can be added in a follow-up.

Ref: #51340, #38109
@cla-bot

cla-bot Bot commented Apr 22, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @lilith on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@probably-neb
probably-neb force-pushed the feat-fs-poll-watching branch from 56ed011 to 7bb3a8d Compare April 22, 2026 08:13
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Apr 22, 2026
@cla-bot

cla-bot Bot commented Apr 22, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @lilith on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@probably-neb

Copy link
Copy Markdown
Collaborator Author

Hey @lilith, I took the time to create a PR on your Polling backend fork.
I ended up reworking it a bit to fit cleanly in with the existing architecture, primarily to re-use the existing watcher deduping logic which I think will be extra important to have for the polling backend.
If you have time to check this out and play around with it to make sure I didn't break anything on your end I'd appreciate it.
I included your commit so that you get credit for your work, but you'll need to sign the CLA in order for me to merge the commit. If you don't want to sign the CLA or for me to use your work, just lmk and I can rewrite the portions I've kept untouched (primarily the detection of when to use the poll backend)

@cla-bot

cla-bot Bot commented Apr 22, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @lilith on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@lilith

lilith commented Apr 22, 2026 via email

Copy link
Copy Markdown
Contributor

@probably-neb

Copy link
Copy Markdown
Collaborator Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 23, 2026
@cla-bot

cla-bot Bot commented Apr 23, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@probably-neb
probably-neb marked this pull request as ready for review April 23, 2026 08:53
Co-authored-by: Ben Kunkle <ben@zed.dev>

@kubkon kubkon 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.

Looks great!

@kubkon
kubkon added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit aeb602d Apr 23, 2026
31 checks passed
@kubkon
kubkon deleted the feat-fs-poll-watching branch April 23, 2026 11:43
@auwi-nordic

Copy link
Copy Markdown
Contributor

Nice to see, just some notes for future improvements

  1. Why not make the watcher mode and poll interval a real setting? Using environment variable is clunky
  2. Ideally those settings should possible to override on a per-project level

Just for posterity I'd like to note that this change doesn't fully solve the issue of fs watching, and doesn't eliminate the need for manual refresh option as discussed here: #54150

probably-neb pushed a commit that referenced this pull request May 6, 2026
…g callback handlers (#55683) (cherry-pick to preview) (#55941)

Cherry-pick of #55683 to preview

----
In #54481, the `handle_event` function was altered to check for an
`Access` event after the callbacks were acquired via a global state
lock. The lock/Vec-collect has enough overhead (or maybe there's enough
lock contention?) that the handler isn't performant enough to keep up
with the volume of inotify events, and its queue fills up, resulting in
[a rescan event getting

emitted](https://github.com/notify-rs/notify/blob/79007aefb41d9f853d00656eb768600e3ea41ee0/notify/src/inotify.rs#L304-L306),
which presumably results in *more* access events for the file as it's
rescanned, which further serve to fill up the inotify queue.

Moving the check for an `Access` event and returning before doing
anything remotely expensive seems to resolve the issues I've been having
lately. Not sure if it addresses the original issue in #53480 though.

Longer-term, it might be prudent to do the event handler's heavy-lifting
in a separate thread with its own event queue, and let the handler
passed to the `notify` crate be just a dumb `tx` sender.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX

checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Related to #53480
Fixes #55829 

Release Notes:

- Fixed inotify event queue overflows on linux

Co-authored-by: Josh Robson Chase <josh@robsonchase.com>
probably-neb pushed a commit that referenced this pull request May 6, 2026
…g callback handlers (#55683) (cherry-pick to stable) (#55942)

Cherry-pick of #55683 to stable

----
In #54481, the `handle_event` function was altered to check for an
`Access` event after the callbacks were acquired via a global state
lock. The lock/Vec-collect has enough overhead (or maybe there's enough
lock contention?) that the handler isn't performant enough to keep up
with the volume of inotify events, and its queue fills up, resulting in
[a rescan event getting

emitted](https://github.com/notify-rs/notify/blob/79007aefb41d9f853d00656eb768600e3ea41ee0/notify/src/inotify.rs#L304-L306),
which presumably results in *more* access events for the file as it's
rescanned, which further serve to fill up the inotify queue.

Moving the check for an `Access` event and returning before doing
anything remotely expensive seems to resolve the issues I've been having
lately. Not sure if it addresses the original issue in #53480 though.

Longer-term, it might be prudent to do the event handler's heavy-lifting
in a separate thread with its own event queue, and let the handler
passed to the `notify` crate be just a dumb `tx` sender.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX

checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Related to #53480
Fixes #55829 

Release Notes:

- Fixed inotify event queue overflows on linux

Co-authored-by: Josh Robson Chase <josh@robsonchase.com>
StrongTheDev pushed a commit to StrongTheDev/zed that referenced this pull request May 6, 2026
…g callback handlers (zed-industries#55683)

In zed-industries#54481, the `handle_event` function was altered to check for an
`Access` event after the callbacks were acquired via a global state
lock. The lock/Vec-collect has enough overhead (or maybe there's enough
lock contention?) that the handler isn't performant enough to keep up
with the volume of inotify events, and its queue fills up, resulting in
[a rescan event getting
emitted](https://github.com/notify-rs/notify/blob/79007aefb41d9f853d00656eb768600e3ea41ee0/notify/src/inotify.rs#L304-L306),
which presumably results in *more* access events for the file as it's
rescanned, which further serve to fill up the inotify queue.

Moving the check for an `Access` event and returning before doing
anything remotely expensive seems to resolve the issues I've been having
lately. Not sure if it addresses the original issue in zed-industries#53480 though.

Longer-term, it might be prudent to do the event handler's heavy-lifting
in a separate thread with its own event queue, and let the handler
passed to the `notify` crate be just a dumb `tx` sender.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Related to zed-industries#53480
Fixes zed-industries#55829 

Release Notes:

- Fixed inotify event queue overflows on linux
pull Bot pushed a commit to Zezo-Ai/zezo-ai that referenced this pull request May 8, 2026
…s#56165)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#56064

This behavior regressed in
zed-industries#54481

Release Notes:

- Fixed an issue where broken symlinks, permission errors, or other fs
errors in watched directories could cause excessive CPU usage
probably-neb added a commit that referenced this pull request May 8, 2026
…ry-pick to preview) (#56174)

Cherry-pick of #56165 to preview

----
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX

checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #56064

This behavior regressed in
#54481

Release Notes:

- Fixed an issue where broken symlinks, permission errors, or other fs
errors in watched directories could cause excessive CPU usage

Co-authored-by: Ben Kunkle <ben@zed.dev>
probably-neb added a commit that referenced this pull request May 8, 2026
…ry-pick to stable) (#56175)

Cherry-pick of #56165 to stable

----
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX

checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #56064

This behavior regressed in
#54481

Release Notes:

- Fixed an issue where broken symlinks, permission errors, or other fs
errors in watched directories could cause excessive CPU usage

Co-authored-by: Ben Kunkle <ben@zed.dev>
kathbigra pushed a commit to kathbigra/zed that referenced this pull request May 10, 2026
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#51340
Release Notes:

- Linux/WSL: Added polling filesystem watching support in order to
support file watching on file systems that do emit events through
`inotify`, for example `/mnt/c` in WSL, network filesystems, and FUSE
mounts. Polling should be automatically chosen over `inotify` when
necessary, however it can be manually chosen by setting the
`ZED_FILE_WATCHER_MODE=poll` env var

---------

Co-authored-by: Lilith River <lilith@imazen.io>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
Nkr1shna pushed a commit to neozed-industries/neo-zed that referenced this pull request May 11, 2026
…s#56165) (cherry-pick to stable) (zed-industries#56175)

Cherry-pick of zed-industries#56165 to stable

----
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX

checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#56064

This behavior regressed in
zed-industries#54481

Release Notes:

- Fixed an issue where broken symlinks, permission errors, or other fs
errors in watched directories could cause excessive CPU usage

Co-authored-by: Ben Kunkle <ben@zed.dev>
Nkr1shna pushed a commit to neozed-industries/neo-zed that referenced this pull request May 13, 2026
…s#56165) (cherry-pick to stable) (zed-industries#56175)

Cherry-pick of zed-industries#56165 to stable

----
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX

checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#56064

This behavior regressed in
zed-industries#54481

Release Notes:

- Fixed an issue where broken symlinks, permission errors, or other fs
errors in watched directories could cause excessive CPU usage

Co-authored-by: Ben Kunkle <ben@zed.dev>
ubunatic pushed a commit to ubunatic/zed that referenced this pull request May 16, 2026
…g callback handlers (zed-industries#55683)

In zed-industries#54481, the `handle_event` function was altered to check for an
`Access` event after the callbacks were acquired via a global state
lock. The lock/Vec-collect has enough overhead (or maybe there's enough
lock contention?) that the handler isn't performant enough to keep up
with the volume of inotify events, and its queue fills up, resulting in
[a rescan event getting
emitted](https://github.com/notify-rs/notify/blob/79007aefb41d9f853d00656eb768600e3ea41ee0/notify/src/inotify.rs#L304-L306),
which presumably results in *more* access events for the file as it's
rescanned, which further serve to fill up the inotify queue.

Moving the check for an `Access` event and returning before doing
anything remotely expensive seems to resolve the issues I've been having
lately. Not sure if it addresses the original issue in zed-industries#53480 though.

Longer-term, it might be prudent to do the event handler's heavy-lifting
in a separate thread with its own event queue, and let the handler
passed to the `notify` crate be just a dumb `tx` sender.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Related to zed-industries#53480
Fixes zed-industries#55829 

Release Notes:

- Fixed inotify event queue overflows on linux
jasonsmithio pushed a commit to paddleboarddev/paddleboard that referenced this pull request May 31, 2026
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries/zed#56064

This behavior regressed in
zed-industries/zed#54481

Release Notes:

- Fixed an issue where broken symlinks, permission errors, or other fs
errors in watched directories could cause excessive CPU usage
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#51340
Release Notes:

- Linux/WSL: Added polling filesystem watching support in order to
support file watching on file systems that do emit events through
`inotify`, for example `/mnt/c` in WSL, network filesystems, and FUSE
mounts. Polling should be automatically chosen over `inotify` when
necessary, however it can be manually chosen by setting the
`ZED_FILE_WATCHER_MODE=poll` env var

---------

Co-authored-by: Lilith River <lilith@imazen.io>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…g callback handlers (zed-industries#55683)

In zed-industries#54481, the `handle_event` function was altered to check for an
`Access` event after the callbacks were acquired via a global state
lock. The lock/Vec-collect has enough overhead (or maybe there's enough
lock contention?) that the handler isn't performant enough to keep up
with the volume of inotify events, and its queue fills up, resulting in
[a rescan event getting
emitted](https://github.com/notify-rs/notify/blob/79007aefb41d9f853d00656eb768600e3ea41ee0/notify/src/inotify.rs#L304-L306),
which presumably results in *more* access events for the file as it's
rescanned, which further serve to fill up the inotify queue.

Moving the check for an `Access` event and returning before doing
anything remotely expensive seems to resolve the issues I've been having
lately. Not sure if it addresses the original issue in zed-industries#53480 though.

Longer-term, it might be prudent to do the event handler's heavy-lifting
in a separate thread with its own event queue, and let the handler
passed to the `notify` crate be just a dumb `tx` sender.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Related to zed-industries#53480
Fixes zed-industries#55829 

Release Notes:

- Fixed inotify event queue overflows on linux
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…s#56165)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#56064

This behavior regressed in
zed-industries#54481

Release Notes:

- Fixed an issue where broken symlinks, permission errors, or other fs
errors in watched directories could cause excessive CPU usage
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#51340
Release Notes:

- Linux/WSL: Added polling filesystem watching support in order to
support file watching on file systems that do emit events through
`inotify`, for example `/mnt/c` in WSL, network filesystems, and FUSE
mounts. Polling should be automatically chosen over `inotify` when
necessary, however it can be manually chosen by setting the
`ZED_FILE_WATCHER_MODE=poll` env var

---------

Co-authored-by: Lilith River <lilith@imazen.io>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…g callback handlers (zed-industries#55683)

In zed-industries#54481, the `handle_event` function was altered to check for an
`Access` event after the callbacks were acquired via a global state
lock. The lock/Vec-collect has enough overhead (or maybe there's enough
lock contention?) that the handler isn't performant enough to keep up
with the volume of inotify events, and its queue fills up, resulting in
[a rescan event getting
emitted](https://github.com/notify-rs/notify/blob/79007aefb41d9f853d00656eb768600e3ea41ee0/notify/src/inotify.rs#L304-L306),
which presumably results in *more* access events for the file as it's
rescanned, which further serve to fill up the inotify queue.

Moving the check for an `Access` event and returning before doing
anything remotely expensive seems to resolve the issues I've been having
lately. Not sure if it addresses the original issue in zed-industries#53480 though.

Longer-term, it might be prudent to do the event handler's heavy-lifting
in a separate thread with its own event queue, and let the handler
passed to the `notify` crate be just a dumb `tx` sender.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Related to zed-industries#53480
Fixes zed-industries#55829 

Release Notes:

- Fixed inotify event queue overflows on linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PollWatcher fallback for WSL, network filesystems, and FUSE mounts

4 participants