Skip to content

fs: Pre-filter the event kind before acquiring global lock and cloning callback handlers (#55683) (cherry-pick to stable) - #55942

Merged
probably-neb merged 1 commit into
v1.1.xfrom
cherry-pick-v1.1.x-7ba7b4b9
May 6, 2026
Merged

fs: Pre-filter the event kind before acquiring global lock and cloning callback handlers (#55683) (cherry-pick to stable)#55942
probably-neb merged 1 commit into
v1.1.xfrom
cherry-pick-v1.1.x-7ba7b4b9

Conversation

@zed-zippy

@zed-zippy zed-zippy Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

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
,
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:

  • 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

Related to #53480
Fixes #55829

Release Notes:

  • Fixed inotify event queue overflows on linux

…g callback handlers (#55683)

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
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 6, 2026
@zed-community-bot zed-community-bot Bot added the bot Pull requests authored by a bot label May 6, 2026
@probably-neb
probably-neb enabled auto-merge (squash) May 6, 2026 19:41
@probably-neb
probably-neb merged commit 1938a7a into v1.1.x May 6, 2026
39 checks passed
@probably-neb
probably-neb deleted the cherry-pick-v1.1.x-7ba7b4b9 branch May 6, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot Pull requests authored by a bot cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants