You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
File watcher resulting in high CPU use on Mac/Linux for large folders #3998
We are using chokidar for file watching. Chokidar is known for performing bad over large folders (see paulmillr/chokidar#410). To investigate:
can we consume a newer version of chokidar with the scalability issue fixed
can we change our watching strategy to only watch what we need instead of always watching root
can we switch to another watching library that is more efficient
Workaround:
Find the large folders in your workspace and add them under the files.watcherExclude setting
Reacted by Matt DeClaire, Kevin Kucharczyk, Sibelius Seraphini, Lachlan Heywood, Aykut Çevik, Dylan v.d Merwe, Sean Gerhardt, 哈哈胡子, Joona Heikkilä, ishanray and 117 more
Benjamin Pasero (@bpasero) i'll keep an eye on improving the scalability in chokidar to fit into the release. Let me know if you have a specific test repo (with large folders?) to check the performance.
The "files.watcherExclude" doesn't work. A huge repo is constantly stuck at 100% all cpus even if i disabled everything: "files.watcherExclude": {"**/**" : true}. Any other workarounds? I've done it also for search.exclude
Plan is to move to a new file watcher on all platforms that does:
allow to natively exclude folders via files.watcherExclude (currently the exclude is applied not very efficiently in JS code)
does not recursively scan the watched folder on startup [1]
[1]
On Linux, watching a workspace requires to walk the hierarchy all the way down and attach listeners on each folder on the way. But with supporting files.watcherExclude natively on the level of the watcher, this should improve drastically when you exclude large folders as needed.
Tomorrows insider build will ship with the new watcher.
Reacted by Hans, electrovir, Nuthan Hegde, Joshua Sleeper and Wilmer Cantillo
Not sure if this is the "tomorrow's build", but just downloaded and seeing this:
That was asking VSC to monitor my entire ~ folder. A lot. If I narrow it to my dev work, it's pretty reasonable.... down to .1%, total cpu goes from 8% -> 2%. So, this appears to be addressing the problem on my machine...
Linux users: when you configure files.watcherExclude, we currently do not support recursive glob matching for exclusions, so please configure an exclude rule that is either:
the full absolute path of a folder to ignore
the workspace relative path of a folder to ignore
We have some cleverness to convert a exclude pattern such as **/node_modules/** into a path of <workspace folder>/node_modules, so in most cases the existing exclusion rules should work unless they are more complicated than that.
@bpasero Not sure if this is to be expected, but 1 of the two processes, is still using 17k file inotifys for me. The other 1 is recuded down to 3k when using the insider build.
The process that is still using the 17k is started as soon as I open a typescript file within my project: /home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/node --max-old-space-size=3072 /home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /tmp/vscode-typescript1000/34436af53053e9135e28/tscancellation-c3bde92247843ca61b50.tmp* --globalPlugins typescript-vscode-sh-plugin --pluginProbeLocations /home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/extensions/typescript-language-features --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation
The one that was actually reduced from 17k to 3k is: /home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/node /home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/out/bootstrap-fork --type=watcherServiceParcel
I am not sure if this is to be expected or this fixes only half of the problem?
Activity
paulmillr commentedon Mar 15, 2016
Benjamin Pasero (@bpasero) i'll keep an eye on improving the scalability in chokidar to fit into the release. Let me know if you have a specific test repo (with large folders?) to check the performance.
bpasero commentedon Mar 15, 2016
Some good ones are TypeScript (https://github.com/Microsoft/TypeScript) and of course the full Chromium workspace is probably the largest I know: https://chromium.googlesource.com/chromium/src.git
paulmillr commentedon Mar 15, 2016
Just checked TypeScript, it consumes around 80% of one core for ~2 seconds and then it's back to 0%.
Cloning Chromium.
paulmillr commentedon Mar 15, 2016
Although when
useFsEventsisfalse(non-default option on OSX), the CPU usage becomes terrible.I'll investigate the new PR in chokidar too.
127 remaining items
karrtikr commentedon Sep 14, 2021
Can we detect if it's a large folder, and decide whether we want to enable watcher accordingly?
A-Sam commentedon Sep 18, 2021
The
"files.watcherExclude"doesn't work. A huge repo is constantly stuck at 100% all cpus even if i disabled everything:"files.watcherExclude": {"**/**" : true}. Any other workarounds? I've done it also forsearch.excludebpasero commentedon Oct 11, 2021
Plan is to move to a new file watcher on all platforms that does:
files.watcherExclude(currently the exclude is applied not very efficiently in JS code)[1]
On Linux, watching a workspace requires to walk the hierarchy all the way down and attach listeners on each folder on the way. But with supporting
files.watcherExcludenatively on the level of the watcher, this should improve drastically when you exclude large folders as needed.Tomorrows insider build will ship with the new watcher.
valhuber commentedon Oct 12, 2021
Version: 1.62.0-insider (Universal)
Commit: e96a974
Date: 2021-10-11T05:14:31.072Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0
Not sure if this is the "tomorrow's build", but just downloaded and seeing this:
That was asking VSC to monitor my entire ~ folder. A lot. If I narrow it to my dev work, it's pretty reasonable.... down to .1%, total cpu goes from 8% -> 2%. So, this appears to be addressing the problem on my machine...
bpasero commentedon Oct 12, 2021
Today's insider build includes the new file watcher: https://code.visualstudio.com/insiders/
Linux users: when you configure
files.watcherExclude, we currently do not support recursive glob matching for exclusions, so please configure an exclude rule that is either:We have some cleverness to convert a exclude pattern such as
**/node_modules/**into a path of<workspace folder>/node_modules, so in most cases the existing exclusion rules should work unless they are more complicated than that.A-Sam commentedon Oct 12, 2021
Tested the master on Linux and this problem doesn't exist anymore.
Thanks @bpasero and the devs for the efforts it was a real headache to kill it upon every startup.
jrmyio commentedon Oct 26, 2021
@bpasero Not sure if this is to be expected, but 1 of the two processes, is still using 17k file inotifys for me. The other 1 is recuded down to 3k when using the insider build.
The process that is still using the 17k is started as soon as I open a typescript file within my project:
/home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/node --max-old-space-size=3072 /home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /tmp/vscode-typescript1000/34436af53053e9135e28/tscancellation-c3bde92247843ca61b50.tmp* --globalPlugins typescript-vscode-sh-plugin --pluginProbeLocations /home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/extensions/typescript-language-features --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocationThe one that was actually reduced from 17k to 3k is:
/home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/node /home/test/.vscode-server-insiders/bin/dc1a6699060423b8c4d2ced736ad70195378fddf/out/bootstrap-fork --type=watcherServiceParcelI am not sure if this is to be expected or this fixes only half of the problem?
bpasero commentedon Oct 27, 2021
@jrmyio please protest in this issue https://github.com/microsoft/TypeScript/issues/46351