Skip to content

Comments

feat(LanguageServer): debounce onDidChangeWatchedFiles events#1626

Open
bartvandenende-wm wants to merge 3 commits intorokucommunity:masterfrom
bartvandenende-wm:feature/debounce-file-watch-events
Open

feat(LanguageServer): debounce onDidChangeWatchedFiles events#1626
bartvandenende-wm wants to merge 3 commits intorokucommunity:masterfrom
bartvandenende-wm:feature/debounce-file-watch-events

Conversation

@bartvandenende-wm
Copy link
Contributor

@bartvandenende-wm bartvandenende-wm commented Feb 15, 2026

Context

In large multi-project workspaces, rapid file-system events (e.g. git operations, bulk saves) each trigger a full processing cycle fanned out to all projects, causing CPU spikes. This is part 1 of 3 targeted improvements to language server performance at scale (Part of #1625).

Summary

Debounces onDidChangeWatchedFiles to collapse rapid successive events into a single batched processing cycle.

  • Accumulates file-change events in a buffer and flushes after a configurable delay (default 300ms)
  • Rebuilds PathFilterer at most once per batch when config files change
  • Reduces processing from O(events × projects) to O(projects) per burst

Test plan

  • New tests verify batching of rapid successive events into one handleFileChanges call
  • New tests verify debounce timer resets on each new event
  • New tests verify rebuildPathFilterer called at most once per batch
  • Existing tests pass with debounce delay set to 0

When the client sends rapid successive file change notifications (e.g.
during VCS operations, package installs, or bulk builds), the language
server now accumulates changes in a buffer and flushes them after a
configurable debounce window (default 300ms). This reduces redundant
work by batching multiple notifications into a single processing pass
instead of handling each one individually.

Key changes:
- Add pendingFileChanges buffer and configurable fileChangeDebounceDelay
- Debounce timer resets on each new event, coalescing rapid changes
- rebuildPathFilterer is called at most once per batch
- Cleanup timer on dispose

Co-authored-by: Cursor <cursoragent@cursor.com>
@bartvandenende-wm bartvandenende-wm force-pushed the feature/debounce-file-watch-events branch from 8af04ea to c68d2f5 Compare February 15, 2026 15:25
bartvandenende-wm and others added 2 commits February 16, 2026 11:18
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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