Skip to content

UpdateProjectIfDirty is slow on large projectsΒ #60633

Closed
@dbaeumer

Description

@dbaeumer

πŸ”Ž Search Terms

UpdateProjectIfDirty language server slow

πŸ•— Version & Regression Information

  • tested the version that ships with VS Code

⏯ Playground Link

No response

πŸ’» Code

Steps to reproduce:

Observe: updateGraphWorker takes roughly 300ms on my machine

I took a performance trace and a lot of time is spent in GC and getNormalizedAbsolutePath. I added a simply unbound cache to the method like

const pathCache = new Map();
function getNormalizedAbsolutePath(fileName, currentDirectory) {
  let cache = pathCache.get(currentDirectory);
  if (cache === undefined) {
    cache = new Map();
    pathCache.set(currentDirectory, cache);
  }
  let normalized = cache.get(fileName);
  if (normalized === undefined) {
    normalized = getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
    cache.set(fileName, normalized);
  }
  return normalized;
}

which cuts the time for updateGraphWorker in half. However there are still some GCs going on and a lot of time is now spent in verifyCompilerOptions / getNormalizedPathComponents.

πŸ™ Actual behavior

Takes 300ms to update on key stroke

πŸ™‚ Expected behavior

Adding a new line should be even in large project only cost a couple of ms :-)

Additional information about the issue

No response

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions