Repository navigation
Fix GPUI branch watcher read-feedback loop on Linux - #946
Merged
Merged
Conversation
The chat screen's git branch watcher forwarded any event whose path ended in HEAD, regardless of event kind. On Linux, inotify reports the app's own branch reads as open/read/close access events, so each read retriggered the watcher: ~100k HEAD reads in 2 seconds and ~200% CPU while idle (#945). Filter by event kind: forward semantic changes (modify, create, remove, rename, and the unclassified Any/Other kinds) and required rescans, and drop access-only events. Writes still arrive as Modify on every backend, so no real branch change is lost, and the directory watch stays so atomic HEAD replacement during checkout keeps working. Adds unit coverage for the new predicate: access-only HEAD events do not schedule a refresh, real change kinds and atomic replacements still do, unrelated paths never do, and required rescans always do. macOS was never affected: the FSEvents backend has no read/open/close event kinds (898k probe reads produced zero events). Linux runtime verification is pending on the reporter's machine. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #945.
Problem
The chat screen's git branch watcher forwarded any
notifyevent whose path ended inHEAD, regardless of event kind. On Linux, the inotify backend reports the app's own branch reads as open/read/close-after-read access events, so eachread_branchretriggered the watcher in a feedback loop: ~100kHEADreads in 2 seconds, ~200% CPU while idle, fans spinning non-stop.Fix
watch_branchnow filters through ahead_change_eventpredicate that forwards:HEADpath (modify, create, remove, rename pairs from atomic replacement)Any/Otherkinds some backends emit for real changesand drops access-only events (open, read, close). Writes still arrive as
Modifyon every backend, so no real branch change is lost, and the directory watch stays so atomicHEADreplacement during checkout keeps working.Tests
New
test_head_watch_ignores_read_access_eventscovers the regression list from the issue: access-only HEAD events never schedule a refresh, real change kinds and atomic replacements still do, unrelated paths never do, and required rescans always do.just cipasses (fmt, clippy with-D warningsacross feature sets, all test suites).Platform notes
HEADreads in 5s against a live watch and received zero events, while an atomicHEADreplacement was still detected.Built from the
head-watch-945maple-dev-env workspace on4178b1cc.