-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix 100% CPU caused due to FS watchers when using liveshare #20006
Fix 100% CPU caused due to FS watchers when using liveshare #20006
Conversation
@@ -179,7 +179,7 @@ function watchRoots(args: WatchRootsArgs): IDisposable { | |||
|
|||
function createWorkspaceLocator(ext: ExtensionState): WorkspaceLocators { | |||
const locators = new WorkspaceLocators(watchRoots, [ | |||
(root: vscode.Uri) => [new WorkspaceVirtualEnvironmentLocator(root.fsPath), new PoetryLocator(root.fsPath)], | |||
(root: vscode.Uri) => [new WorkspaceVirtualEnvironmentLocator(root), new PoetryLocator(root.fsPath)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is PeotryLocator safe? if root happen to have pyproject.toml on guest live share box, it might start to execute some shell commands on the remote machine? feels like getRoots needs to be changed to Uri and any locator that assumes file:// need to deal with non local uri?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The WorkspaceEnvironmentLocator seems to be the only one that doesn't pass a file to the file watcher. All the others seem to pass an exact file to look for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But yeah they should all use the uri. I didn't want to make that big of a change though. It ripples all over the place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karthiknadig thoughts? Should I switch them all to use a URI and check the scheme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait I just realized what Heejae was suggesting. It doesn't look it the locator runs any code, but callers of this might.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@karrtikr Can you answer the question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discovering or watching for Python interpreters doesn't make sense in vsls:/
, as it's a virtual workspace. So I think ideally discovery component should be disabled as a whole. The issue is that we're initializing FS watchers in the constructor itself: #20023.
For now try checking if it's a virtual workspace before activating the watchers here:
vscode-python/src/client/pythonEnvironments/base/locators/common/resourceBasedLocator.ts
Line 39 in 76f7763
this.ensureWatchersReady().ignoreErrors(); |
Changes to URI are then not needed. Add:
export async function isVirtualWorkspace(): Promise<boolean> {
const service = internalServiceContainer.get<IWorkspaceService>(IWorkspaceService);
return service.isVirtualWorkspace;
}
in externalDependencies.ts
and import it here.
Plan to have a look tomorrow, marking as draft. |
@@ -179,7 +179,7 @@ function watchRoots(args: WatchRootsArgs): IDisposable { | |||
|
|||
function createWorkspaceLocator(ext: ExtensionState): WorkspaceLocators { | |||
const locators = new WorkspaceLocators(watchRoots, [ | |||
(root: vscode.Uri) => [new WorkspaceVirtualEnvironmentLocator(root.fsPath), new PoetryLocator(root.fsPath)], | |||
(root: vscode.Uri) => [new WorkspaceVirtualEnvironmentLocator(root), new PoetryLocator(root.fsPath)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discovering or watching for Python interpreters doesn't make sense in vsls:/
, as it's a virtual workspace. So I think ideally discovery component should be disabled as a whole. The issue is that we're initializing FS watchers in the constructor itself: #20023.
For now try checking if it's a virtual workspace before activating the watchers here:
vscode-python/src/client/pythonEnvironments/base/locators/common/resourceBasedLocator.ts
Line 39 in 76f7763
this.ensureWatchersReady().ignoreErrors(); |
Changes to URI are then not needed. Add:
export async function isVirtualWorkspace(): Promise<boolean> {
const service = internalServiceContainer.get<IWorkspaceService>(IWorkspaceService);
return service.isVirtualWorkspace;
}
in externalDependencies.ts
and import it here.
traceError(ex); | ||
this.watchersReady?.reject(ex); | ||
}); | ||
this.watchersReady.resolve(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be outside the if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, duh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should test again. It might have been working just because the promise never resolved.
…hiodo/vscode-python into rchiodo/filewatcher_liveshare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to merge after testing is done.
…/vscode-python#20006) Fixes microsoft/vscode-python#20005 Root cause is roots coming from liveshare. Liveshare gives a workspaceFolder of `vsls:/`.
Fixes #20005
Root cause is roots coming from liveshare. Liveshare gives a workspaceFolder of
vsls:/
.