Skip to content
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

Cache getConstraintOfDistributiveConditionalType #53358

Conversation

jakebailey
Copy link
Member

For #51188

In the perf graphs of #53346, a lot of the time is spent in getConstraintOfDistributiveConditionalType. We can cache it like getDefaultConstraintOfConditionalType. This function can return undefined, so we have to use a different value than undefined to indicate this case (as undefined is "not yet calculated").

On top of main, this nets:

Benchmark 1: main
  Time (mean ± σ):     19.155 s ±  0.163 s    [User: 16.576 s, System: 2.573 s]
  Range (min … max):   18.905 s … 19.563 s    20 runs
 
Benchmark 2: new
  Time (mean ± σ):     16.842 s ±  0.352 s    [User: 14.326 s, System: 2.511 s]
  Range (min … max):   16.315 s … 18.002 s    20 runs
 
Summary
  'new' ran
    1.14 ± 0.03 times faster than 'main'

This compounds with #53346; both together nets:

Benchmark 1: main
  Time (mean ± σ):     19.118 s ±  0.241 s    [User: 16.597 s, System: 2.513 s]
  Range (min … max):   18.626 s … 19.485 s    20 runs
 
Benchmark 2: new
  Time (mean ± σ):     11.757 s ±  0.296 s    [User: 10.019 s, System: 1.732 s]
  Range (min … max):   11.218 s … 12.257 s    20 runs
 
Summary
  'new' ran
    1.63 ± 0.05 times faster than 'main'

Verified

This commit was signed with the committer’s verified signature. The key has expired.
mjcarroll Michael Carroll
…Type
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Mar 19, 2023
@jakebailey
Copy link
Member Author

@typescript-bot test this
@typescript-bot test top100
@typescript-bot user test this
@typescript-bot run dt
@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 19, 2023

Heya @jakebailey, I've started to run the abridged perf test suite on this PR at 5301906. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 19, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 5301906. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 19, 2023

Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at 5301906. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 19, 2023

Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 5301906. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 19, 2023

Heya @jakebailey, I've started to run the extended test suite on this PR at 5301906. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/53358/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

Comparison Report - main..53358

Metric main 53358 Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 361,043k (± 0.01%) 361,063k (± 0.01%) ~ 361,022k 361,092k p=0.230 n=6
Parse Time 3.53s (± 0.87%) 3.52s (± 0.61%) ~ 3.49s 3.55s p=0.808 n=6
Bind Time 1.18s (± 0.46%) 1.18s (± 0.44%) ~ 1.18s 1.19s p=0.640 n=6
Check Time 9.48s (± 0.49%) 9.44s (± 0.13%) ~ 9.42s 9.45s p=0.124 n=6
Emit Time 7.93s (± 0.82%) 7.91s (± 0.59%) ~ 7.86s 7.99s p=0.747 n=6
Total Time 22.13s (± 0.53%) 22.05s (± 0.20%) ~ 21.99s 22.10s p=0.470 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 192,558k (± 0.02%) 192,546k (± 0.04%) ~ 192,451k 192,641k p=0.689 n=6
Parse Time 1.59s (± 0.86%) 1.57s (± 1.42%) ~ 1.54s 1.59s p=0.067 n=6
Bind Time 0.82s (± 0.63%) 0.82s (± 0.00%) ~ 0.82s 0.82s p=0.174 n=6
Check Time 10.15s (± 0.87%) 10.07s (± 0.74%) ~ 9.98s 10.16s p=0.286 n=6
Emit Time 3.00s (± 0.25%) 2.99s (± 0.95%) ~ 2.96s 3.04s p=0.164 n=6
Total Time 15.56s (± 0.51%) 15.46s (± 0.68%) ~ 15.36s 15.61s p=0.108 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,570k (± 0.01%) 345,572k (± 0.00%) ~ 345,549k 345,588k p=0.689 n=6
Parse Time 2.73s (± 0.60%) 2.72s (± 0.60%) ~ 2.70s 2.74s p=0.088 n=6
Bind Time 1.09s (± 0.47%) 1.09s (± 1.00%) ~ 1.08s 1.11s p=0.324 n=6
Check Time 7.70s (± 0.41%) 7.69s (± 0.29%) ~ 7.67s 7.73s p=0.421 n=6
Emit Time 4.46s (± 0.49%) 4.44s (± 0.88%) ~ 4.39s 4.49s p=0.332 n=6
Total Time 15.98s (± 0.35%) 15.94s (± 0.44%) ~ 15.85s 16.02s p=0.298 n=6
TFS - node (v16.17.1, x64)
Memory used 299,817k (± 0.01%) 299,807k (± 0.01%) ~ 299,760k 299,856k p=0.689 n=6
Parse Time 2.17s (± 0.54%) 2.18s (± 0.80%) ~ 2.16s 2.21s p=0.251 n=6
Bind Time 1.24s (± 0.97%) 1.24s (± 0.85%) ~ 1.22s 1.25s p=0.282 n=6
Check Time 7.17s (± 0.54%) 7.16s (± 0.49%) ~ 7.10s 7.20s p=0.629 n=6
Emit Time 4.34s (± 0.63%) 4.36s (± 0.61%) ~ 4.32s 4.39s p=0.624 n=6
Total Time 14.93s (± 0.24%) 14.94s (± 0.38%) ~ 14.86s 15.00s p=0.748 n=6
material-ui - node (v16.17.1, x64)
Memory used 476,408k (± 0.01%) 476,407k (± 0.00%) ~ 476,369k 476,427k p=0.471 n=6
Parse Time 3.21s (± 0.61%) 3.22s (± 0.33%) ~ 3.20s 3.23s p=1.000 n=6
Bind Time 0.95s (± 0.43%) 0.95s (± 0.54%) ~ 0.95s 0.96s p=0.595 n=6
Check Time 17.91s (± 0.86%) 17.90s (± 0.69%) ~ 17.76s 18.12s p=0.748 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.08s (± 0.62%) 22.07s (± 0.57%) ~ 21.93s 22.29s p=0.688 n=6
xstate - node (v16.17.1, x64)
Memory used 550,624k (± 0.02%) 550,652k (± 0.02%) ~ 550,529k 550,780k p=0.689 n=6
Parse Time 3.95s (± 0.16%) 3.94s (± 0.35%) ~ 3.92s 3.96s p=0.510 n=6
Bind Time 1.80s (± 0.29%) 1.79s (± 0.29%) ~ 1.79s 1.80s p=0.311 n=6
Check Time 3.04s (± 0.34%) 3.05s (± 0.93%) ~ 3.01s 3.08s p=0.332 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 8.88s (± 0.17%) 8.88s (± 0.29%) ~ 8.86s 8.92s p=1.000 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 53358 6
Baseline main 6

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/53358/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@sandersn sandersn requested review from rbuckton and weswigham March 27, 2023 18:32
@@ -6630,6 +6630,8 @@ export interface ConditionalType extends InstantiableType {
/** @internal */
resolvedDefaultConstraint?: Type;
/** @internal */
resolvedDefaultConstraintOfDistributed?: Type | false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resolvedDefaultConstraintOfDistributed?: Type | false;
resolvedDefaultConstraintOfDistributive?: Type | false;

it'd be weird to not match the function name, y'know. Plus, a distributive conditional we're getting the distributive constraint of can't have been distributed yet, since, if it was, we wouldn't have a distributive conditional anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, then maybe this should really just be resolvedConstraintOfDistributive to match the function? I think I brainfarted when copying the declaration above to rename it and just kept the word "default" without thinking about it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to the straight substring of the function name, which isn't exactly what you said but I think is actually correct.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
mjcarroll Michael Carroll
…lType

Verified

This commit was signed with the committer’s verified signature. The key has expired.
mjcarroll Michael Carroll
@jakebailey jakebailey merged commit 3efcfcb into microsoft:main Mar 27, 2023
@jakebailey jakebailey deleted the faster-getConstraintOfDistributiveConditionalType branch March 27, 2023 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants