-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Optimize union type creation #53771
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
Optimize union type creation #53771
Conversation
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 46d1c4e. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 46d1c4e. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at 46d1c4e. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the diff-based top-repos suite on this PR at 46d1c4e. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at 46d1c4e. You can monitor the build here. Update: The results are in! |
@ahejlsberg Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
@ahejlsberg Here they are:Comparison Report - main..53771
System
Hosts
Scenarios
Developer Information: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
@ahejlsberg Here are the results of running the top-repos suite comparing Everything looks good! |
Hey @ahejlsberg, the results of running the DT tests are ready. |
@typescript-bot perf test this faster |
Heya @jakebailey, I've started to run the abridged perf test suite on this PR at 14f30d3. You can monitor the build here. Update: The results are in! |
@jakebailey Here they are:Comparison Report - main..53771
System
Hosts
Scenarios
Developer Information: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved x2 😄
This PR implements two optimizations to our union type creation logic:
Record<A, B>[A]
, whereA
andB
are large union types, we end up creating a union type from a list of typesB
,B
, ...,B
, whereB
is repeated as many times as the size ofA
. The union type creation logic collects the constituent type list by "flattening" eachB
, which ends up generating a lot of useless work. We now detect that we've already processedB
and ignore all but the first occurrence.U | undefined
whereU
is some large union type.The check time for the example in #53761 effectively drops to zero with these optimizations.
Fixes #53761.