fix: use NonRecursive mode for individual file watchers (APP-4657)#12188
Draft
warp-dev-github-integration[bot] wants to merge 1 commit into
Draft
fix: use NonRecursive mode for individual file watchers (APP-4657)#12188warp-dev-github-integration[bot] wants to merge 1 commit into
warp-dev-github-integration[bot] wants to merge 1 commit into
Conversation
register_file_path() and fallback_to_individual_watchers() were using RecursiveMode::Recursive with WatchFilter::accept_all() when falling back to individual file watchers. On Linux, this causes the inotify backend to walk the entire directory tree and register a watch on every subdirectory, which can consume gigabytes of memory in large trees (observed 4.8 GB in heap profiles from Sentry). The fix aligns both code paths with the approach already used by open(), which watches the parent directory with NonRecursive mode. This is sufficient for detecting file changes while avoiding the explosive inotify watch growth. Co-Authored-By: Oz <oz-agent@warp.dev>
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.
Description
Fix excessive memory usage from inotify recursive watch registration on Linux.
register_file_path()andfallback_to_individual_watchers()inwarp_files/src/lib.rswere usingRecursiveMode::RecursivewithWatchFilter::accept_all()when falling back to individual file watchers. On Linux with inotify, this causes the notify crate to walk the entire directory tree and register a watch on every subdirectory. In large directory trees, this creates millions of PathBuf entries in the internal watches HashMap, consuming gigabytes of memory (observed 4.8 GB in Sentry heap profiles — 96.5% of sampled heap innotify::inotify::EventLoop::add_watch).The fix aligns both code paths with the approach already used by
open(), which watches the parent directory withNonRecursivemode. This is sufficient for detecting file changes while avoiding the explosive inotify watch growth. Theunsubscribe()cleanup already expected parent-directory-based watching.Linked Issue
APP-4657
Sentry Issue
Testing
cargo check -p warp_filescargo clippy -p warp_files -- -D warnings./script/runAgent Mode
Conversation: https://staging.warp.dev/conversation/322f80c3-3bfc-4435-92dc-497b389fbb70
Run: https://oz.staging.warp.dev/runs/019e91d1-786f-7cd1-8825-283b9314965b
This PR was generated with Oz.