Skip to content
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

Inefficient file watching #140398

Closed
bpasero opened this issue Jan 10, 2022 · 1 comment
Closed

Inefficient file watching #140398

bpasero opened this issue Jan 10, 2022 · 1 comment
Assignees
Labels
debt Code quality issues file-watcher File watcher insiders-released Patch has been released in VS Code Insiders perf
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Jan 10, 2022

Came across this code:

private doesChangeAffects(change: IFileChange, extensionsResource: URI): boolean {
// Is not immediate child of extensions resource
if (!this.uriIdentityService.extUri.isEqual(this.uriIdentityService.extUri.dirname(change.resource), extensionsResource)) {
return false;
}
// .obsolete file changed
if (this.uriIdentityService.extUri.isEqual(change.resource, this.uriIdentityService.extUri.joinPath(extensionsResource, '.obsolete'))) {
return true;
}
// Only interested in added/deleted changes
if (change.type !== FileChangeType.ADDED && change.type !== FileChangeType.DELETED) {
return false;
}
// Ingore changes to files starting with `.`
if (this.uriIdentityService.extUri.basename(change.resource).startsWith('.')) {
return false;
}
return true;
}

I think it can be improved:

  • do the cheap checks first (i.e. the change type check)
  • do not do a manual check for parent via dirname, there is isEqualOrParent
@bpasero bpasero added the file-watcher File watcher label Jan 10, 2022
@bpasero bpasero added the perf label Jan 10, 2022
@sandy081 sandy081 added the debt Code quality issues label Jan 11, 2022
@sandy081 sandy081 added this to the January 2022 milestone Jan 11, 2022
@sandy081 sandy081 modified the milestones: January 2022, February 2022 Jan 24, 2022
@sandy081 sandy081 modified the milestones: February 2022, March 2022 Feb 11, 2022
@sandy081 sandy081 modified the milestones: March 2022, April 2022 Mar 21, 2022
@sandy081
Copy link
Member

do not do a manual check for parent via dirname, there is isEqualOrParent

I want to check if the resource is an immediate child of another resource, for that, isEqualOrParent is not enough, I have to do isEqual check too. Instead I am just checking if parent of the resource is equal to the target resource. I think both shall be equally optimistic.

@github-actions github-actions bot locked and limited conversation to collaborators May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues file-watcher File watcher insiders-released Patch has been released in VS Code Insiders perf
Projects
None yet
Development

No branches or pull requests

3 participants
@bpasero @sandy081 and others