-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Slow intellisense with large TS enum (3000+ rows) #42824
Comments
Works pretty quickly for me with just that enum (a quarter second at most) Could is there something else in your project that causes this? Do you see this with all extensions disabled too? |
I would try out the instructions at https://github.com/microsoft/TypeScript/wiki/Performance#performance-tracing first. This may help pinpoint what work is taking up a lot of time in type-checking. CCing @amcasey in case he has any questions or can clarify anything |
An enum like that won't be slow on its own - only where it is consumed. @woophi, if you don't already have a sample usage in mind, you can use the tool @DanielRosenwasser linked to identify the part of your code that's taking a long time to check. If you provide a sample usage, we should be able to figure out whether your code and/or the compiler needs to be tweaked. It would also be helpful to know which version of TypeScript you're using (sorry if it's in the metadata and I missed it) and, as @mjbvz suggested, you'll probably want to try again without extensions (e.g. tslint). |
Thanks for help. I have tried to use performance-tracing tool and found a place where the problem was. By this commit you can see how I ve resolved it |
Excellent, glad you're unblocked. Thanks so much for the repro! |
It turns out that running a large enum through Immer's Draft is very expensive. I'm still investigating how extracting |
@amcasey After commenting some part of code in data.ts, I found what was the reason. |
@woophi A few follow-up questions if you don't mind:
|
Got it! Using the type alias makes it obvious to the compiler that the type is not generic and does not participate in type inference (see |
When `Draft<T>` is applied to a large enum type, TypeScript has to do a lot of unnecessary structural comparisons to confirm that no element of the enum matches `Function`, `Date`, `RegExp`, etc. Determining that they do match `string` or `number`, on the other hand, is trivial. This change splits `PrimitiveType` out of `AtomicObject` so that the fast path can be checked first. In microsoft/TypeScript#42824, this cut the check time from ~2.5 seconds to ~0.3 seconds.
Issue Type: Performance Issue
I have a large enum with 3000+ rows. https://pastebin.com/uBXCNxSb
When I try to access some methods or types that have imported this enum - it takes about 20-60 seconds to resolve autocomplete or autoimport.
Do you have any advice or thoughts - how to speed up it?
VS Code version: Code 1.53.2 (622cb03f7e070a9670c94bae1a45d78d7181fbd4, 2021-02-11T11:48:04.245Z)
OS version: Windows_NT x64 10.0.19042
System Info
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Process Info
Workspace Info
Extensions (11)
A/B Experiments
The text was updated successfully, but these errors were encountered: