-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Performance slowdown on recursive type in 4.3 and 4.4, fixed in 4.5 #47052
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
Comments
The risk/reward calculation for backporting that fix to prior releases doesn't pencil out IMO -- it's too possible that this could break someone else and leave them completely stuck, whereas people needing the fix 4.2 and 4.5 as safe spots. |
What fix are you referring to? |
For folks that stumble upon this issue, we've merged a fix that replaced the mapped object type property access w/ |
The performance fix you're asking be ported |
@RyanCavanaugh I don't know what that fix is (in 4.5+), that's what I'm trying to figure out. I did mention a PR in the description which I think is the reason why things became slower. |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow or the TypeScript Discord community. |
Bug Report
I'm maintaining a type that infers the response type for an Elasticsearch request based on its input. After upgrading to 4.3.5 in the Kibana repo Intellisense has become terribly slow for us and one place where I see a pretty big slowdown is in these types (which all of our APIs depend on). After manually bisecting some changes between 4.2 and 4.3 I'm suspecting #43527 is the culprit.
The type is a recursive one, but not directly (ie, it calls itself via other types it creates).
From looking at the trace data that TS itself generates and profiling via pprof I see a lot of time is being spent in getVariancesWorker (via getAliasVariances) and recursiveTypeRelatedTo/structuredTypeRelatedTo.
Is there a better way to write these types that work with 4.3 and 4.4 in a reasonable manner? If not, is it possible that whatever fixed it in 4.5 is backported to 4.3? I'm not expecting is to be able to upgrade to 4.5 any time soon, we just completed a painful upgrade to 4.3.
🔎 Search Terms
recursive type, tail-recursive, union, map, performance, getVariancesWorker, getRecursionIdentity, getVariancesWorker, recursiveTypeRelatedTo, structuredTypeRelatedTo
4.2.3, 4.3.5, 4.4.4, 4.5.2
🕗 Version & Regression Information
This changed between versions 4.2.3 and 4.3.5
⏯ Playground Link
https://ela.st/faster-typescript-es-perf
If you uncomment the bottom line and re-type it you should be able to see a huge difference in responsiveness in 4.2/4.5 vs 4.3/4.4.
💻 Code
See playground link.
🙁 Actual behavior
Autocompletion takes a long time (+5s).
🙂 Expected behavior
Autocompletion should be instant.
The text was updated successfully, but these errors were encountered: