Skip to content

Fixed cache key computation for tuple target types with partially named members #55695

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

Merged
merged 1 commit into from
Sep 11, 2023

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Sep 9, 2023

fixes #55693

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 9, 2023
@@ -16392,10 +16392,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// [...X[]] is equivalent to just X[]
return readonly ? globalReadonlyArrayType : globalArrayType;
}
const memberIds = mapDefined(namedMemberDeclarations, node => node ? getNodeId(node) : undefined);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this would previously compute the same cache key segment for [undefined, labelNode] and [labelNode, undefined]

const key = map(elementFlags, f => f & ElementFlags.Required ? "#" : f & ElementFlags.Optional ? "?" : f & ElementFlags.Rest ? "." : "*").join() +
(readonly ? "R" : "") +
(memberIds.length ? "," + memberIds.join(",") : "");
(some(namedMemberDeclarations, node => !!node) ? "," + map(namedMemberDeclarations, node => node ? getNodeId(node) : "_").join(",") : "");
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to precheck rather than just doing the map and letting it give the empty string via returning nothing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, not rly - this only keeps the cache key shorter if there are no named members.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I misread this and didn't notice that this was adding a conditional prefix. Just seemed less nice to double iterate but it's fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I debugged this down in a moment between things so I didn't exactly give it an extended thought at that moment. It was previously added conditionally and I didn't spend a second thinking if this would still be needed after things change.

Since you called it out, I re-evaluated it and I think it is, indeed, redundant now. So I would be more than OK with dropping this. Unlabeled tuples are probably more common than labeled ones though but I doubt that the cache key size would impact perf in a significant way.

Copy link
Member

Choose a reason for hiding this comment

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

All good, I'd just leave it as it's not a regression.

@jakebailey
Copy link
Member

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 11, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 11, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 11, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 11, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Unknown failure"
  • 2 instances of "Package install failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 300,276k (± 0.01%) 300,282k (± 0.01%) ~ 300,256k 300,309k p=0.470 n=6
Parse Time 3.01s (± 0.18%) 3.01s (± 0.30%) ~ 3.00s 3.02s p=0.341 n=6
Bind Time 0.93s (± 0.00%) 0.93s (± 0.00%) ~ 0.93s 0.93s p=1.000 n=6
Check Time 9.31s (± 0.32%) 9.32s (± 0.27%) ~ 9.29s 9.35s p=0.807 n=6
Emit Time 7.61s (± 0.37%) 7.62s (± 0.10%) ~ 7.61s 7.63s p=0.418 n=6
Total Time 20.86s (± 0.24%) 20.88s (± 0.14%) ~ 20.83s 20.90s p=0.627 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,987k (± 0.02%) 193,926k (± 0.02%) -61k (- 0.03%) 193,852k 193,972k p=0.031 n=6
Parse Time 1.58s (± 0.52%) 1.58s (± 0.00%) ~ 1.58s 1.58s p=0.405 n=6
Bind Time 0.79s (± 0.69%) 0.79s (± 0.65%) ~ 0.79s 0.80s p=0.640 n=6
Check Time 9.94s (± 0.27%) 9.92s (± 0.50%) ~ 9.86s 9.97s p=0.687 n=6
Emit Time 2.74s (± 0.27%) 2.74s (± 0.30%) ~ 2.73s 2.75s p=0.729 n=6
Total Time 15.05s (± 0.20%) 15.03s (± 0.34%) ~ 14.96s 15.08s p=0.629 n=6
Monaco - node (v16.17.1, x64)
Memory used 347,178k (± 0.01%) 347,172k (± 0.01%) ~ 347,108k 347,196k p=0.378 n=6
Parse Time 2.69s (± 0.15%) 2.68s (± 0.19%) -0.01s (- 0.31%) 2.68s 2.69s p=0.022 n=6
Bind Time 0.99s (± 0.00%) 0.99s (± 0.00%) ~ 0.99s 0.99s p=1.000 n=6
Check Time 7.94s (± 0.21%) 7.93s (± 0.29%) ~ 7.90s 7.96s p=0.517 n=6
Emit Time 4.27s (± 0.15%) 4.27s (± 0.38%) ~ 4.24s 4.29s p=0.720 n=6
Total Time 15.88s (± 0.12%) 15.87s (± 0.14%) ~ 15.84s 15.90s p=0.145 n=6
TFS - node (v16.17.1, x64)
Memory used 301,182k (± 0.01%) 301,181k (± 0.00%) ~ 301,172k 301,192k p=0.748 n=6
Parse Time 2.18s (± 0.69%) 2.17s (± 0.63%) ~ 2.16s 2.19s p=1.000 n=6
Bind Time 1.11s (± 0.37%) 1.11s (± 0.37%) ~ 1.11s 1.12s p=0.218 n=6
Check Time 7.23s (± 0.24%) 7.22s (± 0.23%) ~ 7.20s 7.24s p=0.415 n=6
Emit Time 3.98s (± 0.48%) 3.98s (± 0.22%) ~ 3.97s 3.99s p=0.934 n=6
Total Time 14.50s (± 0.28%) 14.49s (± 0.16%) ~ 14.47s 14.53s p=0.519 n=6
material-ui - node (v16.17.1, x64)
Memory used 479,482k (± 0.00%) 479,471k (± 0.00%) -11k (- 0.00%) 479,460k 479,477k p=0.028 n=6
Parse Time 3.15s (± 0.13%) 3.15s (± 0.35%) ~ 3.14s 3.17s p=1.000 n=6
Bind Time 0.91s (± 0.00%) 0.91s (± 0.45%) ~ 0.91s 0.92s p=0.405 n=6
Check Time 17.80s (± 0.29%) 17.76s (± 0.28%) ~ 17.67s 17.82s p=0.141 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 21.86s (± 0.23%) 21.82s (± 0.27%) ~ 21.73s 21.91s p=0.195 n=6
xstate - node (v16.17.1, x64)
Memory used 542,845k (± 0.01%) 542,850k (± 0.01%) ~ 542,786k 542,914k p=0.936 n=6
Parse Time 3.68s (± 0.30%) 3.69s (± 0.38%) ~ 3.67s 3.71s p=0.216 n=6
Bind Time 1.43s (± 3.62%) 1.42s (± 4.13%) ~ 1.34s 1.46s p=0.492 n=6
Check Time 3.18s (± 2.05%) 3.22s (± 2.96%) ~ 3.14s 3.37s p=0.373 n=6
Emit Time 0.09s (± 5.95%) 0.09s (± 6.44%) ~ 0.08s 0.09s p=0.640 n=6
Total Time 8.39s (± 0.36%) 8.42s (± 0.57%) ~ 8.36s 8.50s p=0.296 n=6
System info unknown
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 pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,490ms (± 0.13%) 2,489ms (± 0.20%) ~ 2,479ms 2,492ms p=0.627 n=6
Req 2 - geterr 5,935ms (± 0.32%) 5,933ms (± 0.20%) ~ 5,914ms 5,945ms p=1.000 n=6
Req 3 - references 343ms (± 0.24%) 343ms (± 0.29%) ~ 341ms 344ms p=0.396 n=6
Req 4 - navto 276ms (± 0.72%) 277ms (± 0.44%) ~ 276ms 279ms p=0.108 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 85ms (± 8.41%) 78ms (± 4.31%) ~ 76ms 83ms p=0.113 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,622ms (± 0.53%) 2,614ms (± 0.37%) ~ 2,607ms 2,633ms p=0.261 n=6
Req 2 - geterr 4,772ms (± 0.24%) 4,770ms (± 0.28%) ~ 4,746ms 4,787ms p=1.000 n=6
Req 3 - references 351ms (± 0.18%) 351ms (± 0.24%) ~ 349ms 351ms p=0.340 n=6
Req 4 - navto 270ms (± 1.04%) 268ms (± 0.38%) ~ 267ms 269ms p=0.070 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 79ms (± 0.95%) 79ms (± 0.52%) ~ 78ms 79ms p=0.389 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,705ms (± 0.04%) 2,705ms (± 0.16%) ~ 2,698ms 2,711ms p=0.737 n=6
Req 2 - geterr 1,974ms (± 0.53%) 1,957ms (± 1.06%) ~ 1,920ms 1,980ms p=0.091 n=6
Req 3 - references 140ms (± 1.39%) 139ms (± 2.25%) ~ 134ms 142ms p=1.000 n=6
Req 4 - navto 360ms (± 0.80%) 361ms (± 1.03%) ~ 357ms 365ms p=0.683 n=6
Req 5 - completionInfo count 2,071 (± 0.00%) 2,071 (± 0.00%) ~ 2,071 2,071 p=1.000 n=6
Req 5 - completionInfo 324ms (± 1.93%) 324ms (± 1.59%) ~ 314ms 328ms p=0.623 n=6
System info unknown
Hosts
  • node (v16.17.1, x64)
Scenarios
  • CompilerTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v16.17.1, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v16.17.1, x64)
Execution time 156.46ms (± 0.22%) 156.47ms (± 0.17%) ~ 154.64ms 158.86ms p=0.579 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time 230.82ms (± 0.12%) 231.52ms (± 0.17%) +0.70ms (+ 0.30%) 229.71ms 238.86ms p=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 235.75ms (± 0.12%) 236.21ms (± 0.12%) +0.45ms (+ 0.19%) 235.15ms 242.65ms p=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time 235.89ms (± 0.11%) 235.89ms (± 0.12%) ~ 234.81ms 239.66ms p=0.907 n=600
System info unknown
Hosts
  • node (v16.17.1, x64)
Scenarios
  • tsc-startup - node (v16.17.1, x64)
  • tsserver-startup - node (v16.17.1, x64)
  • tsserverlibrary-startup - node (v16.17.1, x64)
  • typescript-startup - node (v16.17.1, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/55695/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.

@jakebailey jakebailey merged commit 4b0f54f into microsoft:main Sep 11, 2023
@jakebailey
Copy link
Member

Maybe this might be worth a backport given this can end up breaking the new feature in 5.2? @DanielRosenwasser

snovader pushed a commit to EG-A-S/TypeScript that referenced this pull request Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spreading a named tuple slice results in the names being in the wrong position
3 participants