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

Remove getAllAccessorDeclarations from the EmitResolver #57993

Merged

Conversation

weswigham
Copy link
Member

This reduces the coupling between the checker and the transforms a bit. We actually had a getAllAccessorDeclarations in utilities already - the only difference being it required the container node, too (which was readily available at all callsites). Within the checker, the reverse is done - it no longer uses the getAllAccessorDeclarations utilities function, and now reliably uses the symbol-based lookup method the EmitResolver previously exported, and more reliably looks up the type nodes from accessors. (This does not change any baselines yet, because accessors currently disqualify node reuse - another followup will change that.)

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Mar 28, 2024
@weswigham
Copy link
Member Author

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 28, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,685k (± 0.01%) 295,652k (± 0.00%) -33k (- 0.01%) 295,638k 295,658k p=0.041 n=6
Parse Time 2.66s (± 0.37%) 2.67s (± 0.21%) ~ 2.66s 2.67s p=0.201 n=6
Bind Time 0.83s (± 1.00%) 0.83s (± 0.66%) ~ 0.83s 0.84s p=0.855 n=6
Check Time 8.22s (± 0.39%) 8.26s (± 0.25%) +0.05s (+ 0.55%) 8.24s 8.30s p=0.036 n=6
Emit Time 7.06s (± 0.45%) 7.06s (± 0.76%) ~ 7.00s 7.16s p=1.000 n=6
Total Time 18.76s (± 0.17%) 18.83s (± 0.34%) +0.07s (+ 0.35%) 18.77s 18.95s p=0.036 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 193,908k (± 0.98%) 192,656k (± 0.76%) ~ 191,977k 195,653k p=0.230 n=6
Parse Time 1.63s (± 0.51%) 1.64s (± 0.81%) ~ 1.63s 1.66s p=0.506 n=6
Bind Time 0.88s (± 0.93%) 0.88s (± 1.12%) ~ 0.87s 0.89s p=0.862 n=6
Check Time 11.27s (± 0.35%) 11.24s (± 0.35%) ~ 11.19s 11.29s p=0.172 n=6
Emit Time 3.15s (± 0.74%) 3.15s (± 0.37%) ~ 3.13s 3.16s p=0.870 n=6
Total Time 16.94s (± 0.22%) 16.91s (± 0.07%) ~ 16.89s 16.92s p=0.169 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,427k (± 0.01%) 347,420k (± 0.00%) ~ 347,399k 347,447k p=1.000 n=6
Parse Time 3.70s (± 0.85%) 3.70s (± 1.07%) ~ 3.65s 3.76s p=1.000 n=6
Bind Time 1.38s (± 1.48%) 1.38s (± 0.85%) ~ 1.37s 1.40s p=0.245 n=6
Check Time 10.23s (± 0.55%) 10.22s (± 0.44%) ~ 10.14s 10.27s p=0.872 n=6
Emit Time 6.03s (± 0.57%) 6.00s (± 0.50%) ~ 5.96s 6.04s p=0.295 n=6
Total Time 21.33s (± 0.31%) 21.31s (± 0.33%) ~ 21.22s 21.40s p=0.520 n=6
TFS - node (v18.15.0, x64)
Memory used 302,771k (± 0.01%) 302,769k (± 0.01%) ~ 302,747k 302,814k p=0.810 n=6
Parse Time 2.96s (± 0.35%) 2.96s (± 0.97%) ~ 2.91s 3.00s p=1.000 n=6
Bind Time 1.47s (± 0.43%) 1.46s (± 0.84%) ~ 1.44s 1.47s p=0.599 n=6
Check Time 9.23s (± 0.31%) 9.22s (± 0.54%) ~ 9.19s 9.31s p=0.565 n=6
Emit Time 5.30s (± 0.56%) 5.32s (± 0.22%) ~ 5.31s 5.34s p=0.134 n=6
Total Time 18.96s (± 0.24%) 18.97s (± 0.41%) ~ 18.89s 19.10s p=0.936 n=6
material-ui - node (v18.15.0, x64)
Memory used 510,086k (± 0.01%) 510,092k (± 0.01%) ~ 510,037k 510,145k p=1.000 n=6
Parse Time 3.19s (± 0.54%) 3.19s (± 0.34%) ~ 3.18s 3.21s p=0.555 n=6
Bind Time 1.18s (± 0.87%) 1.18s (± 0.83%) ~ 1.17s 1.20s p=0.788 n=6
Check Time 20.63s (± 0.46%) 20.60s (± 0.22%) ~ 20.53s 20.65s p=0.572 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 25.01s (± 0.43%) 24.97s (± 0.19%) ~ 24.90s 25.03s p=0.748 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,744,689k (± 0.00%) 1,744,643k (± 0.00%) -46k (- 0.00%) 1,744,609k 1,744,681k p=0.045 n=6
Parse Time 7.82s (± 0.63%) 7.80s (± 1.00%) ~ 7.70s 7.94s p=0.936 n=6
Bind Time 2.82s (± 0.79%) 2.81s (± 0.62%) ~ 2.79s 2.84s p=0.622 n=6
Check Time 66.82s (± 0.47%) 66.93s (± 0.44%) ~ 66.60s 67.38s p=0.575 n=6
Emit Time 0.16s (± 3.29%) 0.16s (± 2.52%) ~ 0.16s 0.17s p=0.114 n=6
Total Time 77.61s (± 0.41%) 77.71s (± 0.41%) ~ 77.39s 78.15s p=0.688 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,396,441k (± 0.05%) 2,396,300k (± 0.02%) ~ 2,395,672k 2,396,880k p=0.575 n=6
Parse Time 5.00s (± 0.75%) 4.97s (± 0.60%) ~ 4.94s 5.02s p=0.229 n=6
Bind Time 1.91s (± 0.61%) 1.90s (± 0.96%) ~ 1.89s 1.93s p=0.451 n=6
Check Time 33.90s (± 0.26%) 33.86s (± 0.26%) ~ 33.78s 34.02s p=0.336 n=6
Emit Time 2.69s (± 1.40%) 2.69s (± 1.08%) ~ 2.66s 2.73s p=0.809 n=6
Total Time 43.52s (± 0.17%) 43.45s (± 0.15%) ~ 43.41s 43.58s p=0.230 n=6
self-compiler - node (v18.15.0, x64)
Memory used 416,075k (± 0.01%) 416,135k (± 0.01%) +60k (+ 0.01%) 416,097k 416,180k p=0.020 n=6
Parse Time 2.75s (± 0.51%) 2.76s (± 0.50%) ~ 2.74s 2.78s p=0.511 n=6
Bind Time 1.08s (± 0.48%) 1.08s (± 0.38%) ~ 1.08s 1.09s p=0.114 n=6
Check Time 15.43s (± 0.29%) 15.40s (± 0.15%) ~ 15.37s 15.43s p=0.090 n=6
Emit Time 1.13s (± 1.04%) 1.13s (± 2.09%) ~ 1.10s 1.17s p=0.935 n=6
Total Time 20.39s (± 0.27%) 20.37s (± 0.13%) ~ 20.33s 20.40s p=0.126 n=6
vscode - node (v18.15.0, x64)
Memory used 2,898,484k (± 0.00%) 2,898,625k (± 0.00%) +141k (+ 0.00%) 2,898,609k 2,898,658k p=0.005 n=6
Parse Time 12.94s (± 0.44%) 12.98s (± 0.43%) ~ 12.90s 13.05s p=0.334 n=6
Bind Time 4.13s (± 0.37%) 4.13s (± 0.40%) ~ 4.10s 4.15s p=1.000 n=6
Check Time 72.16s (± 0.32%) 71.77s (± 0.41%) ~ 71.30s 72.04s p=0.065 n=6
Emit Time 20.07s (± 7.72%) 19.49s (± 0.48%) ~ 19.39s 19.66s p=0.748 n=6
Total Time 109.30s (± 1.43%) 108.36s (± 0.26%) ~ 107.88s 108.67s p=0.173 n=6
webpack - node (v18.15.0, x64)
Memory used 408,920k (± 0.02%) 408,886k (± 0.02%) ~ 408,750k 409,013k p=0.689 n=6
Parse Time 3.88s (± 0.53%) 3.87s (± 0.61%) ~ 3.83s 3.90s p=0.373 n=6
Bind Time 1.67s (± 1.24%) 1.68s (± 0.62%) ~ 1.67s 1.70s p=0.141 n=6
Check Time 16.89s (± 0.56%) 16.84s (± 0.25%) ~ 16.79s 16.91s p=0.470 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.44s (± 0.39%) 22.39s (± 0.24%) ~ 22.33s 22.48s p=0.296 n=6
xstate - node (v18.15.0, x64)
Memory used 513,422k (± 0.02%) 513,389k (± 0.01%) ~ 513,346k 513,538k p=0.199 n=6
Parse Time 3.28s (± 0.36%) 3.29s (± 0.32%) ~ 3.27s 3.30s p=0.679 n=6
Bind Time 1.57s (± 0.33%) 1.58s (± 0.65%) ~ 1.56s 1.59s p=0.077 n=6
Check Time 2.90s (± 0.68%) 2.91s (± 0.26%) ~ 2.90s 2.92s p=0.803 n=6
Emit Time 0.07s (± 5.69%) 0.07s (± 5.69%) ~ 0.07s 0.08s p=1.000 n=6
Total Time 7.84s (± 0.33%) 7.83s (± 0.19%) ~ 7.82s 7.85s p=1.000 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

Comment on lines +48917 to +48922
if (node.kind === SyntaxKind.Parameter && node.parent.kind === SyntaxKind.SetAccessor) {
const other = getAllAccessorDeclarationsForDeclaration(node.parent as SetAccessorDeclaration).getAccessor;
if (other) {
return getEffectiveReturnTypeNode(other);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Just to be clear, this code is a noop, right? Since we're not actually handling these and no baselines change? This is brand new code, so, checking.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, for now. My goal is to move the full "should this node be reused" logic check into the node builder, to minimize the EmitResolver's API surface. Today, the node builder never has to emit nonlocal types for get and set accessors. If one is missing an annotation, it gets the type the other one has, and if both have the same type, it prints them as a property, rather than accessors. Meanwhile, declaration emit proper obviously leaves accessor declarations as-is nowadays, and uses logic like this to pull the type node from the other accessor when one is missing an annotation. So this is slightly future-looking, in that it enables the node builder to properly reuse nodes for get/set pairs that are missing one type node, even though the declaration emitter doesn't yet ask it to do that (and you can't get an inferred type with a get/set pair without them having differing types, and thus both annotated).

@weswigham weswigham merged commit a73ca90 into microsoft:main Mar 29, 2024
25 checks passed
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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants