-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Description
TypeScript Version: 3.0.1
Search Terms:
typesPackageExists
Performance slow
tsserver
vscode typescript slow
Description
Since TypeScript 3.0, I find the TypeScript language server is slowing down noticeably. I ran VS Code with TSS_DEBUG=8283 code .
to profile where the performance bottleneck is.
Most of the time is spent in findReferences
function (and its descendant). I am using “Reference CodeLens” which I believe to have caused this command to be executed often.
Looking at the “heavy” graph, tsserver
spends most of its time in the typesPackageExists
function.
Looking at the performance chart, findReferences
called typesPackageExists
multiple times.
The function typesPackageExists
appeared in commit 2b9166b:
function typesPackageExists(packageName: string): boolean {
return host.getSourceFiles().some(sf => !!sf.resolvedModules && !!forEachEntry(sf.resolvedModules, r =>
r && r.packageId && r.packageId.name === getTypesPackageName(packageName)));
}
I set up a breakpoint here:
This allows me to see how many source files I have:
Therefore, tsserver in VS Code slows down when both conditions are met:
- References CodeLens is enabled. (Confirmed: Disabling
javascript.referencesCodeLens.enabled
andtypescript.referencesCodeLens.enabled
fixed this issue.) - The project is large.