ionide-vscode-fsharp
ionide-vscode-fsharp copied to clipboard
Ionide/VSCode consuming all of my inotify instances
Describe the bug
When starting watchers like dotnet watch
or vite
I get errors on my linux system because something is consuming all of my 128 inotify instances.
Further analysis shows that Ionide seems to be consuming most of them:
find /proc/*/fd/* -type l -lname 'anon_inode:inotify' -exec sh -c 'cat $(dirname {})/../cmdline; echo ""' \; 2>/dev/null
/usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp /usr/bin/dotnet/home/user/.vscode/extensions/ionide.ionide-fsharp-7.18.0/bin/net7.0/fsautocomplete.dll--state-directory/home/user/.config/Code/User/workspaceStorage/700616795669794e7b1ffe09d82c0eb9/Ionide.Ionide-fsharp ...
Machine info
- OS: Fedora 39
- .NET SDK version: 8.0.0
- Ionide version: 7.18.0
Additional context
I've had this instance of vscode open for a while. I'm not sure what triggers this situation to happen, but something appears to be spinning up lots and lots of instances of this fsautocomplete.dll thing and is consuming all of my inotify instances.
Hello 128 inotify instance doesn't seems like a loot.
If possible you can increase that limit: https://dev.to/rubiin/ubuntu-increase-inotify-watcher-file-watch-limit-kf4
I am not sure if this will helps, but in general on Unix system I set .NET to use Polling for watching files. You can do that by this setting export DOTNET_USE_POLLING_FILE_WATCHER=true
in your .bashrc
or .zshrc
file.
I understand your perspective here, and I'm aware I'd be able to adjust that limit or force it to use a different polling mechanism, but this is the first time I've ever been confronted with this as a problem, and Ionide isn't the only program I run that relies on inotify.
From my perspective this is a clear bug somewhere (whether its a bug in vscode itself or Ionide I can't say), and it shouldn't be consuming 120-some inotify instances just to work on one project in one instance of vscode.
128 instances is the default setting, and for most people running watchers they'll never even come close to that limit if the programs they're running make correct use of this resource.
Also 128 is just the upper bound it ran into where it couldn't spawn any more inotify instances. If something is going haywire and continuing to try and create them even setting it to 600 wouldn't solve the problem - it would just cause Ionide to eventually be consuming 600 inotify instances.
I don't know from my experience VSCode/Ionide is not the only program that has this issues on my machines that's why I proposed to increase the limit.
For now this is a workaround until someone has an idea how to debug this issue or fix it.
Since we use FileSystemWatcher for changes to fsproj and related files it's a dotnet runtime issue. https://github.com/dotnet/runtime/issues/62869
Yeah, but if I understand the API correctly that implies one FileSystemWatcher is one inotify instance? If so, shouldn't Ionide only ever be creating one FileSystemWatcher at a time? Meaning, is something not disposing of FileSystemWatcher's when it should be?
If so, shouldn't Ionide only ever be creating one FileSystemWatcher at a time?
No, we create FileSystemWatcher
to watch F# Projects and related files to know when to schedule msbuild project reloading. This could be many depending on your projects.
Well, in this case I only had one vscode instance open with a slightly modified solution based on https://github.com/elmish/templates/tree/master. Not a large project. I'm testing out Fable for the first time, and then boom I find that Ionide has hogging all of my system's inotify instances.