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

Fix for relating covered discriminants in unions #39393

Merged
merged 1 commit into from
Jul 7, 2020
Merged

Fix for relating covered discriminants in unions #39393

merged 1 commit into from
Jul 7, 2020

Conversation

rbuckton
Copy link
Member

@rbuckton rbuckton commented Jul 2, 2020

In #30779 we added the ability to relate a source type to a target when the target is a discriminated union and the source is covered by the target. This did not work when the target was a union of tuple types as the relationship check would fail when comparing the synthesized index types for each tuple in indexTypesRelatedTo. This was further complicated by the fact that the new variadic tuple type logic added to propertiesRelatedTo fails to exclude relationship checks for non-variable elements whose indices are included in the excludedProperties map.

This PR does two things to address these issues:

  • Adds discriminant exclusion into the tuple-specific branch in propertiesRelatedTo so that it aligns with the existing, non-tuple-specific logic.
  • Skips the indexTypesRelatedTo check when both the source type and the target type are tuples, as the index type check should be sufficiently covered by the tuple-specific branch in propertiesRelatedTo.

Alternatively, rather than skipping the indexTypesRelatedTo check, we could synthesize a copy of the source and target tuple types with the excluded discriminants erased to never so that they are excluded from the index type. That would result in the allocation of types purely to accommodate indexTypesRelatedTo, which would then be subsequently discarded. This seems like an unnecessary cost, as propertiesRelatedTo sufficiently covers the numeric index type case.

Fixes #39357
Fixes #34967

@rbuckton
Copy link
Member Author

rbuckton commented Jul 2, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 2, 2020

Heya @rbuckton, I've started to run the perf test suite on this PR at 8eba362. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 2, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 2, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 2, 2020

Heya @rbuckton, I've started to run the parallelized community code test suite on this PR at 8eba362. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..39393

Metric master 39393 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 344,003k (± 0.02%) 343,525k (± 0.03%) -478k (- 0.14%) 343,310k 343,841k
Parse Time 2.00s (± 0.58%) 2.01s (± 0.67%) +0.00s (+ 0.15%) 1.98s 2.03s
Bind Time 0.82s (± 0.41%) 0.82s (± 0.60%) -0.00s (- 0.49%) 0.81s 0.83s
Check Time 4.72s (± 0.32%) 4.70s (± 0.51%) -0.01s (- 0.30%) 4.65s 4.74s
Emit Time 5.17s (± 0.39%) 5.15s (± 0.70%) -0.02s (- 0.39%) 5.10s 5.26s
Total Time 12.71s (± 0.24%) 12.68s (± 0.47%) -0.04s (- 0.28%) 12.55s 12.86s
Monaco - node (v10.16.3, x64)
Memory used 339,106k (± 0.02%) 339,046k (± 0.02%) -60k (- 0.02%) 338,950k 339,244k
Parse Time 1.58s (± 0.64%) 1.59s (± 0.50%) +0.01s (+ 0.83%) 1.57s 1.61s
Bind Time 0.71s (± 0.63%) 0.71s (± 0.67%) -0.01s (- 0.70%) 0.70s 0.72s
Check Time 4.86s (± 0.50%) 4.86s (± 0.56%) +0.01s (+ 0.16%) 4.81s 4.92s
Emit Time 2.77s (± 0.66%) 2.74s (± 0.41%) -0.03s (- 1.05%) 2.71s 2.76s
Total Time 9.91s (± 0.40%) 9.90s (± 0.39%) -0.02s (- 0.15%) 9.81s 9.98s
TFS - node (v10.16.3, x64)
Memory used 301,981k (± 0.03%) 302,036k (± 0.03%) +55k (+ 0.02%) 301,930k 302,266k
Parse Time 1.21s (± 0.75%) 1.21s (± 0.70%) 0.00s ( 0.00%) 1.19s 1.22s
Bind Time 0.66s (± 1.28%) 0.67s (± 1.12%) +0.01s (+ 0.91%) 0.64s 0.68s
Check Time 4.40s (± 0.53%) 4.36s (± 0.52%) -0.04s (- 0.84%) 4.32s 4.42s
Emit Time 2.88s (± 1.22%) 2.88s (± 0.78%) +0.00s (+ 0.03%) 2.83s 2.94s
Total Time 9.14s (± 0.64%) 9.11s (± 0.36%) -0.03s (- 0.32%) 9.03s 9.20s
material-ui - node (v10.16.3, x64)
Memory used 459,384k (± 0.01%) 459,141k (± 0.01%) -244k (- 0.05%) 458,995k 459,263k
Parse Time 2.05s (± 0.52%) 2.04s (± 0.25%) -0.00s (- 0.20%) 2.03s 2.05s
Bind Time 0.66s (± 1.28%) 0.65s (± 1.08%) -0.01s (- 1.21%) 0.64s 0.67s
Check Time 12.80s (± 0.48%) 12.84s (± 0.80%) +0.04s (+ 0.27%) 12.68s 13.16s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.50s (± 0.44%) 15.53s (± 0.67%) +0.03s (+ 0.17%) 15.37s 15.87s
Angular - node (v12.1.0, x64)
Memory used 321,096k (± 0.03%) 320,726k (± 0.03%) -370k (- 0.12%) 320,519k 320,983k
Parse Time 1.99s (± 0.68%) 1.98s (± 0.75%) -0.01s (- 0.40%) 1.94s 2.00s
Bind Time 0.80s (± 0.85%) 0.80s (± 0.59%) -0.00s (- 0.62%) 0.79s 0.81s
Check Time 4.60s (± 0.47%) 4.60s (± 0.49%) -0.00s (- 0.04%) 4.55s 4.66s
Emit Time 5.34s (± 0.56%) 5.33s (± 0.34%) -0.01s (- 0.13%) 5.30s 5.37s
Total Time 12.73s (± 0.37%) 12.71s (± 0.27%) -0.02s (- 0.20%) 12.64s 12.79s
Monaco - node (v12.1.0, x64)
Memory used 321,518k (± 0.02%) 321,507k (± 0.02%) -11k (- 0.00%) 321,422k 321,645k
Parse Time 1.55s (± 0.83%) 1.54s (± 0.44%) -0.01s (- 0.58%) 1.54s 1.57s
Bind Time 0.69s (± 0.84%) 0.68s (± 0.70%) -0.00s (- 0.58%) 0.67s 0.69s
Check Time 4.65s (± 0.54%) 4.63s (± 0.43%) -0.01s (- 0.30%) 4.60s 4.69s
Emit Time 2.80s (± 0.61%) 2.80s (± 0.73%) +0.00s (+ 0.11%) 2.75s 2.83s
Total Time 9.68s (± 0.38%) 9.66s (± 0.36%) -0.02s (- 0.21%) 9.60s 9.74s
TFS - node (v12.1.0, x64)
Memory used 286,487k (± 0.02%) 286,475k (± 0.02%) -11k (- 0.00%) 286,312k 286,583k
Parse Time 1.23s (± 0.61%) 1.24s (± 1.41%) +0.01s (+ 0.90%) 1.21s 1.29s
Bind Time 0.64s (± 1.20%) 0.64s (± 1.14%) +0.00s (+ 0.47%) 0.63s 0.66s
Check Time 4.26s (± 0.51%) 4.26s (± 0.64%) -0.00s (- 0.07%) 4.17s 4.31s
Emit Time 2.91s (± 0.96%) 2.93s (± 0.74%) +0.02s (+ 0.83%) 2.89s 2.99s
Total Time 9.04s (± 0.45%) 9.07s (± 0.46%) +0.03s (+ 0.34%) 8.97s 9.17s
material-ui - node (v12.1.0, x64)
Memory used 437,699k (± 0.05%) 437,426k (± 0.05%) -273k (- 0.06%) 436,516k 437,639k
Parse Time 2.01s (± 0.47%) 2.02s (± 0.49%) +0.01s (+ 0.35%) 2.00s 2.04s
Bind Time 0.63s (± 1.18%) 0.63s (± 1.05%) 0.00s ( 0.00%) 0.62s 0.65s
Check Time 11.54s (± 0.86%) 11.57s (± 1.06%) +0.03s (+ 0.24%) 11.35s 11.91s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.18s (± 0.70%) 14.22s (± 0.87%) +0.04s (+ 0.25%) 13.98s 14.56s
Angular - node (v8.9.0, x64)
Memory used 340,422k (± 0.02%) 340,050k (± 0.02%) -371k (- 0.11%) 339,923k 340,245k
Parse Time 2.54s (± 0.44%) 2.52s (± 0.27%) -0.02s (- 0.71%) 2.50s 2.53s
Bind Time 0.85s (± 0.89%) 0.85s (± 0.79%) -0.01s (- 0.94%) 0.83s 0.86s
Check Time 5.33s (± 0.55%) 5.35s (± 0.66%) +0.02s (+ 0.36%) 5.29s 5.46s
Emit Time 5.98s (± 0.88%) 5.88s (± 1.67%) -0.09s (- 1.56%) 5.67s 6.06s
Total Time 14.70s (± 0.30%) 14.60s (± 0.81%) -0.10s (- 0.67%) 14.36s 14.80s
Monaco - node (v8.9.0, x64)
Memory used 340,467k (± 0.01%) 340,461k (± 0.01%) -7k (- 0.00%) 340,406k 340,522k
Parse Time 1.87s (± 0.47%) 1.87s (± 0.66%) -0.00s (- 0.16%) 1.85s 1.91s
Bind Time 0.88s (± 0.45%) 0.88s (± 0.45%) 0.00s ( 0.00%) 0.87s 0.89s
Check Time 5.36s (± 0.58%) 5.38s (± 0.60%) +0.02s (+ 0.37%) 5.32s 5.46s
Emit Time 3.22s (± 0.41%) 3.22s (± 0.75%) +0.00s (+ 0.12%) 3.19s 3.29s
Total Time 11.33s (± 0.43%) 11.35s (± 0.47%) +0.02s (+ 0.16%) 11.26s 11.52s
TFS - node (v8.9.0, x64)
Memory used 303,763k (± 0.01%) 303,812k (± 0.02%) +49k (+ 0.02%) 303,635k 303,956k
Parse Time 1.55s (± 0.92%) 1.55s (± 0.32%) -0.00s (- 0.06%) 1.53s 1.55s
Bind Time 0.67s (± 0.67%) 0.67s (± 1.14%) -0.00s (- 0.45%) 0.65s 0.68s
Check Time 4.99s (± 1.47%) 5.02s (± 1.64%) +0.03s (+ 0.64%) 4.84s 5.16s
Emit Time 3.04s (± 3.30%) 3.03s (± 3.07%) -0.01s (- 0.30%) 2.88s 3.20s
Total Time 10.24s (± 0.35%) 10.26s (± 0.53%) +0.02s (+ 0.21%) 10.12s 10.37s
material-ui - node (v8.9.0, x64)
Memory used 463,609k (± 0.01%) 463,357k (± 0.01%) -252k (- 0.05%) 463,264k 463,495k
Parse Time 2.39s (± 0.73%) 2.38s (± 0.22%) -0.01s (- 0.42%) 2.37s 2.39s
Bind Time 0.78s (± 0.98%) 0.77s (± 0.88%) -0.00s (- 0.26%) 0.76s 0.79s
Check Time 17.11s (± 1.10%) 17.23s (± 0.50%) +0.12s (+ 0.70%) 17.07s 17.51s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 20.28s (± 0.99%) 20.38s (± 0.45%) +0.11s (+ 0.54%) 20.22s 20.69s
Angular - node (v8.9.0, x86)
Memory used 195,298k (± 0.03%) 195,097k (± 0.02%) -201k (- 0.10%) 194,989k 195,173k
Parse Time 2.46s (± 0.51%) 2.44s (± 0.40%) -0.01s (- 0.61%) 2.41s 2.46s
Bind Time 0.99s (± 0.75%) 0.98s (± 0.76%) -0.01s (- 0.71%) 0.97s 1.00s
Check Time 4.81s (± 0.44%) 4.79s (± 0.57%) -0.01s (- 0.31%) 4.75s 4.85s
Emit Time 5.91s (± 1.20%) 5.92s (± 1.23%) +0.02s (+ 0.25%) 5.76s 6.09s
Total Time 14.17s (± 0.45%) 14.15s (± 0.55%) -0.02s (- 0.13%) 14.04s 14.38s
Monaco - node (v8.9.0, x86)
Memory used 193,429k (± 0.02%) 193,456k (± 0.02%) +28k (+ 0.01%) 193,356k 193,532k
Parse Time 1.90s (± 0.69%) 1.91s (± 0.80%) +0.01s (+ 0.26%) 1.88s 1.94s
Bind Time 0.70s (± 0.96%) 0.70s (± 0.95%) +0.00s (+ 0.43%) 0.69s 0.72s
Check Time 5.48s (± 0.42%) 5.43s (± 1.33%) -0.04s (- 0.82%) 5.18s 5.57s
Emit Time 2.67s (± 0.89%) 2.71s (± 3.00%) +0.04s (+ 1.42%) 2.64s 3.03s
Total Time 10.74s (± 0.30%) 10.75s (± 0.47%) +0.00s (+ 0.05%) 10.68s 10.87s
TFS - node (v8.9.0, x86)
Memory used 173,700k (± 0.02%) 173,689k (± 0.02%) -11k (- 0.01%) 173,636k 173,793k
Parse Time 1.58s (± 0.87%) 1.60s (± 1.18%) +0.02s (+ 1.01%) 1.56s 1.65s
Bind Time 0.63s (± 0.94%) 0.64s (± 0.75%) +0.00s (+ 0.47%) 0.63s 0.65s
Check Time 4.60s (± 0.38%) 4.64s (± 0.89%) +0.04s (+ 0.87%) 4.57s 4.76s
Emit Time 2.79s (± 0.85%) 2.78s (± 0.67%) -0.01s (- 0.18%) 2.74s 2.83s
Total Time 9.61s (± 0.34%) 9.66s (± 0.50%) +0.05s (+ 0.53%) 9.57s 9.81s
material-ui - node (v8.9.0, x86)
Memory used 262,557k (± 0.02%) 262,394k (± 0.02%) -162k (- 0.06%) 262,243k 262,502k
Parse Time 2.44s (± 0.88%) 2.45s (± 0.56%) +0.01s (+ 0.49%) 2.42s 2.48s
Bind Time 0.67s (± 0.71%) 0.67s (± 1.05%) +0.00s (+ 0.30%) 0.66s 0.69s
Check Time 15.62s (± 0.76%) 15.77s (± 0.71%) +0.15s (+ 0.98%) 15.58s 16.00s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 18.72s (± 0.60%) 18.89s (± 0.62%) +0.17s (+ 0.89%) 18.69s 19.14s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-166-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v8.9.0, x64)
  • material-ui - node (v8.9.0, x86)
Benchmark Name Iterations
Current 39393 10
Baseline master 10

@rbuckton
Copy link
Member Author

rbuckton commented Jul 7, 2020

I noticed some failures in the DT test run. I'm trying to determine if these are existing errors or are due to this change.

@rbuckton
Copy link
Member Author

rbuckton commented Jul 7, 2020

It looks like the DT failures are issues in DT:

@rbuckton rbuckton merged commit b100680 into master Jul 7, 2020
@rbuckton rbuckton deleted the fix39357 branch July 7, 2020 20:12
@rbuckton rbuckton mentioned this pull request Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Equivalence between tuple containing union type and union type of tuples Not assignable Type
3 participants