-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension Host Process can be completely overwhelmed by file system event during background builds, and make extensions stop to response user actions #194341
Comments
loop in @isidorn |
@lifengl for this case it would probably make sense to exclude more directories from watching via the vscode/src/vs/workbench/contrib/files/browser/files.contribution.ts Lines 261 to 269 in aad333b
|
fyi @jrieken on the perf trace that seems to spend a substantial time in vscode/src/vs/workbench/api/common/extHostFileSystemEventService.ts Lines 64 to 89 in b792feb
To figure out if the extension provided pattern matches the event path. If you have ideas how to make this more efficient, please let me know. Maybe there could be a "fast" variant of |
Why do we use |
@lifengl Can you please share the profile that you captured? I don't see this with a similar setup (npm install and watching node_modules) but it might be OS specific. On macOS I see nice, smallish chunks for events that get processed without much blocking |
@jrieken yeah I think
Our glob lib can deal with backslash vs slash fine, i.e. ignores the difference. But I think the leading |
I sent CPU profiles captured earlier to you. it seems to be that Roslyn team chained events, so they may have better ideas on the patterns they have. During build, lots of output items are .dll/.pdb and other files. The number might be exploded due to projects referencing others are coping referenced output into its own output folder. I wonder certain limited globbing patterns can be matched more efficiently without converting a file path, especially ones matching file extensions or an exact file name like /*.cs can be efficiently checked with Uri. patterns like [BasePath]//*.[Extension] might be quite common in real usages. |
also, another consideration is that fsPath will be called once per-watcher registration, and each time it would create a new string, so when an extension adds many watchers (maybe for different folders), it can grow to be a scalability problem. |
One relatively easy optimization would be to re-use the same vscode/src/vs/workbench/api/common/extHostFileSystemEventService.ts Lines 66 to 71 in ce01d80
|
All optimisations aside we can always have a case in which it is just too much. So, in addition to perf fixes we should emit the events in smaller chunks and "pause" in-between |
Opened #194697 to re-use We do throttle file events since a long time given other similar issues: vscode/src/vs/platform/files/node/watcher/parcel/parcelWatcher.ts Lines 97 to 104 in ddf9e92
This throttling happens at the source where we receive them from |
I that case I wonder why the EH stops responding. If the chunks are overly large and the machines not overly slow nothing should be blocked but saturated. |
That's a good change but I doubt the extension has very many file watchers. I am still wondering if we can avoid using and computing |
Alternative trick/hack to avoid recomputing |
I had thought about it, in the end what we really want is
I like |
@lifengl given we fixed this perf issue in insiders, can you try again with insiders and see how performance is for you now? Can you try to reproduce with our nightly insider builds? You can give our preview releases a try from: https://code.visualstudio.com/insiders/ |
I kinda like but dropping would trigger a recompute on the receiving side... It would need some other mechanism |
* watcher - emit `URI` instead of `string` for faster `fsPath` compute (for #194341) * wip * more * adopt * some cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * implement correlation * cleanup * add correlation * undo, leave for later * tests * tests * tests * tests * tests * log cId * simpler correlation id * 💄 * tests * runs * skip normalization * fix tests * tests * fix tests * add `createWatcher` API * partition events in ext host * allow custom excludes * remove disk file change * 💄 * 💄 * 💄 * wire in * wire in
Closing until we hear otherwise. |
…n host (for microsoft#194341) (microsoft#194697) * file watcher - reuse instances of `Uri` in event handlers in extension host (for microsoft#194341) * feedback: save a function call * use `Lazy`
* watcher - emit `URI` instead of `string` for faster `fsPath` compute (for microsoft#194341) * wip * more * adopt * some cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * implement correlation * cleanup * add correlation * undo, leave for later * tests * tests * tests * tests * tests * log cId * simpler correlation id * 💄 * tests * runs * skip normalization * fix tests * tests * fix tests * add `createWatcher` API * partition events in ext host * allow custom excludes * remove disk file change * 💄 * 💄 * 💄 * wire in * wire in
VS code extension host can be completely overwhelmed by file watcher events, and during that period of time, extensions will stop responding to user actions.
Does this issue occur when all extensions are disabled?: No
VS Code Version: 1.82.2
Version: 1.82.2 (user setup)
Commit: abd2f3d
Date: 2023-09-14T05:55:25.390Z
Electron: 25.8.1
ElectronBuildId: 23779380
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS Version:
OS: Windows_NT x64 10.0.22621
Steps to Reproduce:
Take a CPU profile with vs code built-in development tool, the extension host is completely blocked by file system events.
The text was updated successfully, but these errors were encountered: