Skip to content

Optimize workspace/didChangeWatchedFiles handler#49778

Merged
reflectronic merged 2 commits intozed-industries:mainfrom
reflectronic:optimize-didchanegwatchedfiles
Feb 21, 2026
Merged

Optimize workspace/didChangeWatchedFiles handler#49778
reflectronic merged 2 commits intozed-industries:mainfrom
reflectronic:optimize-didchanegwatchedfiles

Conversation

@reflectronic
Copy link
Member

Previously, didChangeWatchedFiles registrations triggered a rebuild of a single GlobSet containing all file watch patterns for the language server. This means that, each time didChangeWatchedFiles is registered, the work it takes to construct the GlobSet increases. This quadratic blowup caused massive lag with language servers which register thousands of watched files (like Roslyn).

Instead, create one GlobSet per registration and try matching them one-by-one each time a file watcher event is raised.


Before you mark this PR as ready for review, make sure that you have:

  • Added a solid test coverage and/or screenshots from doing manual testing
  • Done a self-review taking into account security and performance aspects

Release Notes:

  • Optimized performance for language servers which register many file-watching notifications.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 21, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 21, 2026
@reflectronic reflectronic enabled auto-merge (squash) February 21, 2026 04:16
@reflectronic reflectronic merged commit 21ac361 into zed-industries:main Feb 21, 2026
27 checks passed
reflectronic added a commit that referenced this pull request Feb 22, 2026
reflectronic added a commit that referenced this pull request Feb 22, 2026
Reverts #49778

This seems to have made things much worse in some cases, so I'll have to
think of a different way to fix the original issue.

Release Notes:
- N/A
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.

1 participant