Skip to content

fs: Replace MacWatcher with notify::FsEventWatcher#47322

Merged
Anthony-Eid merged 3 commits intozed-industries:mainfrom
marcocondrache:fs-mac-watcher-bye-bye
Jan 27, 2026
Merged

fs: Replace MacWatcher with notify::FsEventWatcher#47322
Anthony-Eid merged 3 commits intozed-industries:mainfrom
marcocondrache:fs-mac-watcher-bye-bye

Conversation

@marcocondrache
Copy link
Contributor

@marcocondrache marcocondrache commented Jan 21, 2026

Closes #47064
Closes #20806

The previous implementation used Zed's custom fsevent crate, which spawned a dedicated thread for each watched path. On large projects, this could result in 100+ threads just for filesystem watching.

This PR removes the fsevent crate and switches to using notify's FsEventWatcher directly. The notify implementation maintains a single FSEvents stream that watches all paths on one thread. When paths are added or removed, the stream is stopped, the path list is updated, and the stream is restarted.

Ref: https://github.com/notify-rs/notify/blob/main/notify/src/fsevent.rs

As a result, Zed now uses one thread for filesystem watching regardless of how many paths are watched.

Release Notes:

  • On macOS, Zed now uses significantly fewer resources when watching filesystem changes

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 21, 2026
@github-actions github-actions bot added the community champion Issues filed by our amazing community champions! 🫶 label Jan 21, 2026
@marcocondrache marcocondrache changed the title fs: Remove MacWatcher fs: Replace MacWatcher with notify::FsEventWatcher Jan 21, 2026
@Anthony-Eid Anthony-Eid self-assigned this Jan 21, 2026
@marcocondrache
Copy link
Contributor Author

marcocondrache commented Jan 22, 2026

This also reduces the used file descriptors (on Zed repo) by a lot

Before:

image

After:

image

@marcocondrache marcocondrache force-pushed the fs-mac-watcher-bye-bye branch 3 times, most recently from dae7c66 to 4833c3e Compare January 22, 2026 20:24
@Anthony-Eid
Copy link
Contributor

Hoping to review this soon because the file description problem is something we want to fix! Thank you for making progress on this

Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Anthony-Eid added a commit to zed-industries/notify that referenced this pull request Jan 27, 2026
This flag causes the stream to emit events when the watched root directory itself is renamed, deleted, or moved. This matches the behavior of the previous custom fsevent crate used by Zed.

This is needed because we're replacing our MacWatcher with notify: zed-industries/zed#47322
Anthony-Eid added a commit that referenced this pull request Jan 27, 2026
This is in preparation of merging
#47322, because our MacWatcher
implementation was able to watch root directories, and I wanted to
maintain that behavior to decrease the chance of any bugs occurring from
a merge
@Anthony-Eid
Copy link
Contributor

Once #47782 get's merged this PR will be ready to merge as well!

@marcocondrache
Copy link
Contributor Author

Thank you a lot @Anthony-Eid

Anthony-Eid added a commit that referenced this pull request Jan 27, 2026
…47782)

This is in preparation of merging
#47322, because our MacWatcher
implementation was able to watch root directories, and I wanted to
maintain that behavior to decrease the chance of any bugs occurring from
a merge

Note: Release candidate 9 for Notify was created two days ago which
means that a new version is coming out soon. We should update to v9 once
it's released to include bug fixes from upstream.

Release Notes:

- N/A
@Anthony-Eid Anthony-Eid enabled auto-merge (squash) January 27, 2026 18:57
@Anthony-Eid Anthony-Eid merged commit b1f9ca9 into zed-industries:main Jan 27, 2026
27 checks passed
Anthony-Eid added a commit that referenced this pull request Jan 27, 2026
@Anthony-Eid
Copy link
Contributor

@marcocondrache I'm reverting this so I can remerge it tomorrow after releases, thank you for the PR

Anthony-Eid added a commit that referenced this pull request Jan 27, 2026
Reverts #47322. I'm going to remerge this tomorrow
after releases so we get a full week in nightly to catch any bugs
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 community champion Issues filed by our amazing community champions! 🫶

Projects

None yet

2 participants