Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Avoid expensive relationship checking in mapped type member resolution#36754

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ahejlsberg merged 2 commits intomasterfrommappedTypeMemberResolution
Feb 12, 2020

Conversation

@ahejlsberg
Copy link
Member

This PR removes an expensiveisTypeAssignableTo check from mapped type member resolution and replaces it with a shallowermaybeTypeOfKind. The full relationship check can generate a lot of work exploring simplifications and constraints. Replacing it with the shallow check improves total compile time of the repro in#36564 by 8-10% and also resolves circularities I'm seeing in another PR.

Terkwood and jpdenford reacted with hooray emoji
@ahejlsberg
Copy link
MemberAuthor

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

@typescript-bot
Copy link
Collaborator

typescript-bot commentedFeb 12, 2020
edited
Loading

Heya@ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at868b7b9. You can monitor the buildhere. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commentedFeb 12, 2020
edited
Loading

Heya@ahejlsberg, I've started to run the parallelized community code test suite on this PR at868b7b9. You can monitor the buildhere. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commentedFeb 12, 2020
edited
Loading

Heya@ahejlsberg, I've started to run the extended test suite on this PR at868b7b9. You can monitor the buildhere. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commentedFeb 12, 2020
edited
Loading

Heya@ahejlsberg, I've started to run the perf test suite on this PR at868b7b9. You can monitor the buildhere. It should now contribute to this PR's status checks.

Update:The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..36754

Metricmaster36754DeltaBestWorst
Angular - node (v10.16.3, x64)
Memory used359,212k (± 0.02%)358,539k (± 0.02%)-673k (- 0.19%)358,360k358,707k
Parse Time1.63s (± 0.36%)1.62s (± 0.42%)-0.01s (- 0.68%)1.60s1.63s
Bind Time0.88s (± 1.07%)0.88s (± 0.94%)+0.00s (+ 0.11%)0.87s0.90s
Check Time4.65s (± 0.42%)4.66s (± 0.56%)+0.01s (+ 0.15%)4.59s4.72s
Emit Time5.20s (± 0.66%)5.19s (± 0.53%)-0.01s (- 0.19%)5.12s5.24s
Total Time12.36s (± 0.34%)12.35s (± 0.40%)-0.01s (- 0.10%)12.21s12.46s
Monaco - node (v10.16.3, x64)
Memory used364,651k (± 0.01%)364,715k (± 0.01%)+64k (+ 0.02%)364,651k364,770k
Parse Time1.25s (± 0.71%)1.25s (± 0.71%)-0.01s (- 0.56%)1.23s1.27s
Bind Time0.78s (± 0.63%)0.78s (± 0.48%)-0.00s (- 0.13%)0.77s0.78s
Check Time4.68s (± 0.38%)4.67s (± 0.45%)-0.01s (- 0.17%)4.63s4.71s
Emit Time2.87s (± 0.74%)2.88s (± 0.87%)+0.01s (+ 0.38%)2.79s2.91s
Total Time9.58s (± 0.34%)9.57s (± 0.44%)-0.01s (- 0.09%)9.42s9.63s
TFS - node (v10.16.3, x64)
Memory used324,193k (± 0.03%)324,187k (± 0.03%)-6k (- 0.00%)324,017k324,419k
Parse Time0.95s (± 0.55%)0.95s (± 0.52%)-0.01s (- 0.53%)0.94s0.96s
Bind Time0.74s (± 1.28%)0.74s (± 1.25%)+0.01s (+ 0.68%)0.72s0.76s
Check Time4.22s (± 0.55%)4.22s (± 0.36%)-0.00s (- 0.09%)4.19s4.26s
Emit Time3.00s (± 1.02%)2.98s (± 1.00%)-0.01s (- 0.40%)2.92s3.04s
Total Time8.90s (± 0.54%)8.89s (± 0.24%)-0.01s (- 0.15%)8.84s8.94s
Angular - node (v12.1.0, x64)
Memory used334,863k (± 0.02%)334,216k (± 0.07%)-648k (- 0.19%)333,374k334,526k
Parse Time1.58s (± 0.70%)1.57s (± 0.43%)-0.01s (- 0.89%)1.55s1.58s
Bind Time0.87s (± 0.81%)0.87s (± 0.66%)+0.00s (+ 0.46%)0.86s0.89s
Check Time4.57s (± 0.51%)4.57s (± 0.39%)-0.00s (- 0.09%)4.54s4.61s
Emit Time5.36s (± 0.86%)5.39s (± 1.14%)+0.03s (+ 0.50%)5.28s5.55s
Total Time12.39s (± 0.47%)12.39s (± 0.59%)+0.01s (+ 0.07%)12.29s12.60s
Monaco - node (v12.1.0, x64)
Memory used344,581k (± 0.01%)344,536k (± 0.01%)-45k (- 0.01%)344,416k344,623k
Parse Time1.22s (± 0.60%)1.21s (± 0.62%)-0.00s (- 0.33%)1.19s1.22s
Bind Time0.75s (± 1.17%)0.75s (± 0.74%)-0.00s (- 0.27%)0.73s0.76s
Check Time4.54s (± 0.45%)4.54s (± 0.35%)+0.00s (+ 0.02%)4.50s4.56s
Emit Time2.95s (± 0.56%)2.97s (± 1.14%)+0.02s (+ 0.75%)2.91s3.07s
Total Time9.45s (± 0.35%)9.47s (± 0.55%)+0.02s (+ 0.18%)9.37s9.59s
TFS - node (v12.1.0, x64)
Memory used306,431k (± 0.02%)306,397k (± 0.02%)-35k (- 0.01%)306,266k306,604k
Parse Time0.94s (± 0.61%)0.93s (± 0.60%)-0.01s (- 0.85%)0.92s0.95s
Bind Time0.70s (± 1.17%)0.71s (± 1.06%)+0.00s (+ 0.43%)0.70s0.73s
Check Time4.16s (± 0.46%)4.18s (± 0.37%)+0.02s (+ 0.48%)4.15s4.21s
Emit Time3.05s (± 1.27%)3.06s (± 0.51%)+0.01s (+ 0.23%)3.04s3.11s
Total Time8.86s (± 0.47%)8.88s (± 0.30%)+0.02s (+ 0.27%)8.85s8.95s
Angular - node (v8.9.0, x64)
Memory used354,068k (± 0.01%)353,483k (± 0.01%)-586k (- 0.17%)353,349k353,621k
Parse Time2.13s (± 0.69%)2.12s (± 0.31%)-0.01s (- 0.38%)2.11s2.14s
Bind Time0.93s (± 1.08%)0.93s (± 0.48%)-0.00s (- 0.21%)0.92s0.94s
Check Time5.42s (± 0.50%)5.43s (± 0.46%)+0.00s (+ 0.04%)5.38s5.49s
Emit Time6.23s (± 0.66%)6.21s (± 0.70%)-0.02s (- 0.32%)6.10s6.30s
Total Time14.72s (± 0.35%)14.69s (± 0.43%)-0.03s (- 0.20%)14.55s14.84s
Monaco - node (v8.9.0, x64)
Memory used362,949k (± 0.01%)362,987k (± 0.02%)+37k (+ 0.01%)362,864k363,143k
Parse Time1.56s (± 0.48%)1.56s (± 0.37%)-0.00s (- 0.26%)1.55s1.57s
Bind Time0.95s (± 0.38%)0.95s (± 0.35%)+0.00s (+ 0.42%)0.94s0.96s
Check Time5.39s (± 1.60%)5.35s (± 1.35%)-0.04s (- 0.67%)5.22s5.52s
Emit Time3.31s (± 3.84%)3.33s (± 2.83%)+0.03s (+ 0.88%)3.01s3.47s
Total Time11.21s (± 0.72%)11.20s (± 0.50%)-0.01s (- 0.04%)11.04s11.34s
TFS - node (v8.9.0, x64)
Memory used323,510k (± 0.01%)323,495k (± 0.01%)-16k (- 0.00%)323,395k323,567k
Parse Time1.26s (± 0.60%)1.26s (± 0.61%)-0.00s (- 0.32%)1.25s1.28s
Bind Time0.75s (± 0.45%)0.75s (± 0.48%)+0.00s (+ 0.13%)0.75s0.76s
Check Time4.84s (± 0.63%)4.79s (± 0.43%)-0.05s (- 1.14%)4.75s4.83s
Emit Time3.20s (± 0.40%)3.17s (± 0.47%)-0.02s (- 0.75%)3.15s3.21s
Total Time10.06s (± 0.33%)9.98s (± 0.33%)-0.08s (- 0.82%)9.91s10.05s
Angular - node (v8.9.0, x86)
Memory used201,227k (± 0.03%)200,934k (± 0.04%)-293k (- 0.15%)200,798k201,079k
Parse Time2.05s (± 0.50%)2.05s (± 0.60%)+0.00s (+ 0.05%)2.03s2.08s
Bind Time1.06s (± 0.64%)1.06s (± 0.57%)-0.00s (- 0.09%)1.04s1.07s
Check Time4.95s (± 0.64%)4.93s (± 0.33%)-0.02s (- 0.46%)4.89s4.97s
Emit Time6.16s (± 1.92%)6.16s (± 1.94%)+0.00s (+ 0.00%)5.98s6.42s
Total Time14.22s (± 0.72%)14.19s (± 0.80%)-0.03s (- 0.22%)13.99s14.41s
Monaco - node (v8.9.0, x86)
Memory used203,815k (± 0.02%)203,777k (± 0.01%)-38k (- 0.02%)203,736k203,833k
Parse Time1.60s (± 0.52%)1.60s (± 0.53%)-0.01s (- 0.31%)1.58s1.62s
Bind Time0.77s (± 0.44%)0.76s (± 0.65%)-0.01s (- 1.03%)0.76s0.78s
Check Time5.19s (± 1.86%)5.13s (± 0.68%)-0.06s (- 1.21%)5.08s5.23s
Emit Time3.13s (± 2.62%)3.17s (± 1.29%)+0.04s (+ 1.18%)3.07s3.23s
Total Time10.70s (± 0.27%)10.66s (± 0.18%)-0.04s (- 0.36%)10.62s10.71s
TFS - node (v8.9.0, x86)
Memory used182,626k (± 0.02%)182,637k (± 0.01%)+12k (+ 0.01%)182,591k182,704k
Parse Time1.31s (± 0.67%)1.30s (± 0.58%)-0.01s (- 0.77%)1.28s1.31s
Bind Time0.71s (± 0.73%)0.71s (± 0.81%)-0.00s (- 0.14%)0.70s0.72s
Check Time4.59s (± 0.84%)4.56s (± 0.85%)-0.02s (- 0.50%)4.50s4.69s
Emit Time2.95s (± 0.89%)2.97s (± 1.43%)+0.02s (+ 0.81%)2.90s3.09s
Total Time9.55s (± 0.35%)9.54s (± 0.52%)-0.01s (- 0.08%)9.40s9.66s
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)
BenchmarkNameIterations
Current3675410
Baselinemaster10

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished andfailed. I've opened aPR with the baseline diff from master.

@ahejlsberg
Copy link
MemberAuthor

RWC and DT tests are clean (errors are preexisting conditions in master). Only positive effects on performance. I think this one is good to go.

@ahejlsberg
Copy link
MemberAuthor

@amcasey@RyanCavanaugh Can't add you as reviewers (the usual GitHub issue), but please tak a look when you can.

>foo : { [P in keyof T]: T[P]; }

!(a && b);
>!(a && b) :false
Copy link
Member

Choose a reason for hiding this comment

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

so.... this was just...wrong before?a wasT["a"] whichshould have been constrained tonumber | object | undefined, which meansa can be falsey, which means the new result is correct.

Do we fail to includeundefined constraints in our analysis somewhere in control flow?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I believe it's the old issue of not having a good representation for the falsy parts of a higher-order type. For example:

interfaceOptions{a:unknown;b:unknown;}functionfoo<TextendsOptions>(a:T['a'],b:T['b']){constx=a&&b;// Type T['b']}

The type ofx really should beT['b'] unioned with the falsy parts ofT['a'], but even with negated types this would be a pretty ugly type. IIRC we previously decided to leave this as a known design limitation.

SlurpTheo reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

Aw, yeah :(

Copy link
Member

@weswighamweswigham left a comment

Choose a reason for hiding this comment

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

My above remark is moreso that the baseline change maybe indicates a bug elsewhere in the compiler that this change now works around. This, however, seems fine. The "worst case" is that we mix in an extraundefined that's already expressed in the property type's constraint - that's a little uglier for printback, but isn'tsupposed to change semantic meaning much (if any).

Maybe an inline comment on why we're making this change on the appropriate line is relevant, so someone who might come back in the future, looking to cleanup the printback in that edge case, doesn't swap it back and regress perf?

@ahejlsberg
Copy link
MemberAuthor

ahejlsberg commentedFeb 12, 2020
edited
Loading

The "worst case" is that we mix in an extra undefined that's already expressed in the property type's constraint

Yup, that's exactly it.

Maybe an inline comment on why we're making this change on the appropriate line is relevant

Don't think we need a comment. With this change the code is actually more consistent with what we do on the next line to shallowly removeundefined from the type.

But, for this and other reasons, it definitely would make sense to add the repro from#36564 as a performance test case. That way we'll see a 10% regression if someone messes with it.

Copy link
Member

@amcaseyamcasey left a comment

Choose a reason for hiding this comment

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

I don't deeply understand the change, but the baselines diffs all seem like improvements.

@amcasey
Copy link
Member

There are other text search matches forisTypeAssignableTo(undefinedType - should they be updated too?

@ahejlsberg
Copy link
MemberAuthor

@amcasey I saw one more match, but it's fine for that to stay as is.

amcasey reacted with thumbs up emoji

@ahejlsbergahejlsberg merged commit7a1c5b7 intomasterFeb 12, 2020
@jakebaileyjakebailey deleted the mappedTypeMemberResolution branchNovember 7, 2022 17:35
@microsoftmicrosoft locked asresolvedand limited conversation to collaboratorsOct 21, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@weswighamweswighamweswigham approved these changes

+1 more reviewer

@amcaseyamcaseyamcasey approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

@ahejlsbergahejlsberg

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@ahejlsberg@typescript-bot@amcasey@weswigham

[8]ページ先頭

©2009-2025 Movatter.jp