TypeScript: Semantic highlighting (`encodedSemanticClassifications-full`) extremely slow
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.57.0-1623259737
 - OS Version: Debian GNU/Linux 11 (bullseye)
 
In 1.57.0-1623259737 version IntelliSense is terribly slow. I’ve no Idea, what more details should I provide. I’ve tested it on TypeScript/React project (also with all extensions disabled - with the same result - loading hint takes more than 10 seconds).
After downgrade to 1.56.2-1620838498 everything works great.
About this issue
- Original URL
 - State: closed
 - Created 3 years ago
 - Reactions: 24
 - Comments: 65 (18 by maintainers)
 
Why is this closed? It’s not fixed even in latest version. I still see significant performance regression.
I have this same issue on 1.57 and 1.58 (Insider) VSC, noticed Intellisense in VS code slowing down significantly. Downgrading to Typescript 4.2 seems to speed things up by a factor of 10.
Server log attached.
tsserver.log
Hey team,
I’m also experiencing this in the latest one. I’m not sure why it’s closed? Doesn’t happen on my mac though. It only happens on my PC (windows).
When i press save, it takes 4-5s for typescript to update the errors in my vscode
I’ve encountered this as well recently, latence builds (>3s) up as soon as I start to use react-hook-form in a basic react project, which as of
^7.17.4has no dependencies (eg. no ajv anymore).Setting
"editor.semanticHighlighting.enabled": falsedoes not fix the issue but does cut around ~1s of latence (confirmed by the logs).I can’t find any other cause of latence in the two tsserver logs, so it seems to come from somewhere else?
Can confirm that downgrading to
typescript@~4.2does greatly improve the latence issue.Before (no lag):
"editor.semanticHighlighting.enabled": false(lag):<syntax>Log extract<semantic>Log extractReproduction:
npm init vite@latest test-ts-perf -- --template react-tsnpm add react-hook-formsrc/Test.tsxDiagnostics
Using combination of prisma, trpc, zod, react-hook-form. About 12 prisma models so I guess its a lot of generated code. TS version 4 and 5 destroy my CPU with constant 100% utilization. If I downgrade to TS version < 4.5 the issue goes away but I lose all the type inference (zod requires 4.5+) 😕 Please fix performance issue
Edit: I think I figured out a workaround, downgrading to zod 3.19.1 and TS 4.1, seems like the issue is fixed for me
Same here, also using
react-hook-formin a project of around 300-400 files. Super slow intellisense and compilation on Windows@andrewbranch I’ve created a project which I’ve adapted from some production source code: https://github.com/jonohill/tsc-bug-44851
On my (quite old) laptop, running tsc takes ~30s whereas with Typescript 4.2 (or commenting the documented line in main.ts) it only takes ~3s.
I’m encountering this issue as well (latest stable Typescript release, latest VSCode release) and
encodedSemanticClassificationsis definitely the culprit according to the log, other calls in the log take milliseconds, where as this will be upwards of 1000ms per call which occurs multiple times when trying to use intellisense. I checked https://github.com/microsoft/TypeScript/issues/45824 where it seems as thoughajvmay be the culprit, but after removing the two packages that rely on it (eslintandreact-hook-forms) performance wasn’t any better.I’m not sure what else to do at this point. I’ve disabled all plugins, I’ve checked to make sure the
tsconfig.jsonis excluding files appropriately per the troubleshooting documentation, and I’ve removed the packages that others have said were the culprit without any performance improvement.@armanio123 What is the status on addressing this? There hasn’t been an update for nearly 2 months. Is there any chance of simply reverting https://github.com/microsoft/TypeScript/pull/30639 for the 4.5 release as it’s already in beta, or any chance of a fix for this getting in to 4.5.0? I don’t want to use a different editor/TS version for a single project but waiting 3-5 seconds for each intellisense update isn’t feasible.
Edit: It seems like
ajvmay be used elsewhere such as inwebpackbut that isn’t something I can reasonably ditch, so there’s still some potentialajvmay be the root culprit that is exacerbating this issue.The slowness is caused by PR #30639. I’m still looking at options on how to avoid this.
Update: this may be related to TypeScript 4.3? After updating our codebase to TS43 VSCode’s Intellisense has slowed down to a crawl even when using 1.56.2.
Reverting to 1.56 fixed the slowness for me too. Didn’t seem to matter if I used TS 4.2 or 4.3.
Hmm, I’m trying to figure out a way to repro it, it has to be a fairly large repo. Just out of curiosity, where can I find more info about TS language service being only single-threaded? I know node is a single thread but it also uses worker threads no?
I don’t have a great answer for this off the top of my head, but I think it might be illuminating to see the output of a
tsc --extendedDiagnostics, since that gives us all of that information and more.@andrewbranch I did go through the performance wiki (noted this in my original comment but should have clarified more) including a couple of hours trying various things in https://github.com/microsoft/TypeScript/wiki/Performance#investigating-issues before I posted originally. What does the team consider to be a large project in terms of files, library lines, definition lines, etc? I don’t consider this project to be especially large, but maybe I’m wrong there. I’ll see about running through the performance tracing again, maybe something will show up that can help.
Since text can be somewhat unclear I want to clarify I’m not questioning anything you’ve said or trying to argue about it (I agree with your comments). I’ve never encountered this problem before in any TS project so this sort of performance issue and the various components involved are totally new to me.
👍 Sounds good!
@andrewbranch I have already created the issue AJV slows the IntelliSense there and there is an example of project. The issue: https://github.com/ajv-validator/ajv/issues/1667 The example of a project: https://github.com/aarbmx6s/vscode-ajv-issue
I use this approach to comfortable working in VSCode: https://github.com/microsoft/TypeScript/issues/44851#issuecomment-873487095
Repeating my report about this here since #37746 was recently closed.
I’m trying to move on from 3.8.3 for a long time, because it’s the only version which does not kill my productivity. I have an extremely slow code completion in anything higher than 3.8.3. Currently the logs are from TS 4.4.2.
Sometimes resting the cursor over a property/method completely stucks TS server for seconds:
This is code completion when writing a dot after an object, after ~8 seconds I could finally see the property suggestion list:
Another test with VS Code Insiders:
VS Code Insiders version:
VS Code version:
My main question is, how can I find out exactly what are the expressions in this project (70k+ LoC), that are creating these problems? Any help is much appreciated. Thank you!
Alright I’ve been looking into it and seems like it’s going to be complicated to optimize. All the problem is that typescript is doing a bit more work to relate conditional types (in this example the problem is with type
UncheckedJSONSchemaTypeon filenode_modules/ajv/dist/types/json-schema.d.ts)Nevertheless, we can still get into a good performance by dividing the type into sub named types. I’ve done some tests and manage to get
encodedSemanticClassifications-fullto about a second just by doing that.Check the gist with how the file look after testing: https://gist.github.com/armanio123/95a33f9ad3286a7d78590eb11af293c4
I don’t know much about the project, so all my types on the example are named just an alphabet letter.