Limit the FileSystemWatchers to one per drive root for DefaultFileChangeWatcher#82211
Merged
Limit the FileSystemWatchers to one per drive root for DefaultFileChangeWatcher#82211
Conversation
…eChangeWatcher Context
JoeRobich
commented
Jan 29, 2026
a737e20 to
475bf23
Compare
dibarbet
reviewed
Jan 30, 2026
Member
dibarbet
left a comment
There was a problem hiding this comment.
def @jasonmalinowski to take a look. wonder if locks would actually be simpler here
.../Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/SimpleFileChangeWatcher.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/SimpleFileChangeWatcher.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/SimpleFileChangeWatcher.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/SimpleFileChangeWatcher.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/SimpleFileChangeWatcher.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/SimpleFileChangeWatcher.cs
Outdated
Show resolved
Hide resolved
...lysis.LanguageServer/HostWorkspace/FileWatching/SimpleFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...nguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/SimpleFileChangeWatcherTests.cs
Outdated
Show resolved
Hide resolved
...guageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/DefaultFileChangeWatcherTests.cs
Show resolved
Hide resolved
...nguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/SimpleFileChangeWatcherTests.cs
Outdated
Show resolved
Hide resolved
...guageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/DefaultFileChangeWatcherTests.cs
Outdated
Show resolved
Hide resolved
...nguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/SimpleFileChangeWatcherTests.cs
Outdated
Show resolved
Hide resolved
Member
Author
|
@dibarbet @jasonmalinowski this is ready for another look |
dibarbet
approved these changes
Feb 2, 2026
Member
jasonmalinowski
left a comment
There was a problem hiding this comment.
Another round; still some concerns in the implementation of FileChangeContext but I'm liking where this is heading.
...aces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposableCache.cs
Outdated
Show resolved
Hide resolved
...Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
jasonmalinowski
approved these changes
Feb 3, 2026
Member
jasonmalinowski
left a comment
There was a problem hiding this comment.
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) |
Member
There was a problem hiding this comment.
It's unfortunate there's not an API we can just call that does this for us.
...guageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/DefaultFileChangeWatcherTests.cs
Outdated
Show resolved
Hide resolved
...guageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/DefaultFileChangeWatcherTests.cs
Outdated
Show resolved
Hide resolved
...aces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposableCache.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
...ysis.LanguageServer/HostWorkspace/FileWatching/DefaultFileChangeWatcher.FileChangeContext.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Jason Malinowski <jason.malinowski@microsoft.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.
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