Skip to content

Limit the FileSystemWatchers to one per drive root for DefaultFileChangeWatcher#82211

Merged
JoeRobich merged 8 commits intomainfrom
dev/jorobich/improve-filechangewatcher
Feb 3, 2026
Merged

Limit the FileSystemWatchers to one per drive root for DefaultFileChangeWatcher#82211
JoeRobich merged 8 commits intomainfrom
dev/jorobich/improve-filechangewatcher

Conversation

@JoeRobich
Copy link
Member

@JoeRobich JoeRobich commented Jan 29, 2026

To reduce the number of inotify instances, instead of creating individual file watchers for watched directories and file, we will create a watcher for the drive root and share it across contexts.

resolves #82198

@JoeRobich JoeRobich changed the title Limit the FileSystemWatchers to one per drive root for each SimpleFileChangeWatcher Context Limit the FileSystemWatchers to one per drive root for all SimpleFileChangeWatchers Jan 29, 2026
@JoeRobich JoeRobich force-pushed the dev/jorobich/improve-filechangewatcher branch from a737e20 to 475bf23 Compare January 30, 2026 05:53
@JoeRobich JoeRobich changed the title Limit the FileSystemWatchers to one per drive root for all SimpleFileChangeWatchers Limit the FileSystemWatchers to one per drive root for a SimpleFileChangeWatcher Jan 30, 2026
@JoeRobich JoeRobich marked this pull request as ready for review January 30, 2026 18:26
@JoeRobich JoeRobich requested review from a team as code owners January 30, 2026 18:26
Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def @jasonmalinowski to take a look. wonder if locks would actually be simpler here

@JoeRobich
Copy link
Member Author

@dibarbet @jasonmalinowski this is ready for another look

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another round; still some concerns in the implementation of FileChangeContext but I'm liking where this is heading.

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; a few nits here or there but I think this is functionally correct; there's some perf issues (especially given we're having to go to the root) but "slow" is generally better than "crashes", so that's a win.

// can cause issues when watching files under the temp directory, as the FileSystemWatcher will report changes using the real path.
// So, we need to adjust this path by walking up the temp path until we find a directory that is a link and resolve it.

if (tempDirectory.LinkTarget != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate there's not an API we can just call that does this for us.

JoeRobich and others added 2 commits February 2, 2026 18:55
Co-authored-by: Jason Malinowski <jason.malinowski@microsoft.com>
@JoeRobich JoeRobich changed the title Limit the FileSystemWatchers to one per drive root for a SimpleFileChangeWatcher Limit the FileSystemWatchers to one per drive root for DefaultFileChangeWatcher Feb 3, 2026
@JoeRobich JoeRobich merged commit faa020a into main Feb 3, 2026
28 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roslyn-language-server on linux hits inotify limits

5 participants