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

Track source and target relationship stack depth seperately, only increase on change in value #41821

Merged
merged 16 commits into from
Sep 30, 2021

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Dec 4, 2020

Fixes #41617
Fixes #43485
Fixes #44404

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Dec 4, 2020
@@ -63,4 +64,6 @@ tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' c

type Conv<T, U = T> =
{ 0: [T]; 1: Prepend<T, Conv<ExactExtract<U, T>>>;}[U extends T ? 0 : 1];
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2321: Excessive stack depth comparing types 'Conv<ExactExtract<U, T>, ExactExtract<U, T>>' and 'unknown[]'.
Copy link
Member Author

@weswigham weswigham Dec 4, 2020

Choose a reason for hiding this comment

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

This part of this test was originally added because it had bad perf, and the test had a stack out error once the perf was fixed (circa #32079), however the error disappeared in #40971 and we just kidna didn't care (the test is for perf, after all). Turns out, the error should still be here, since the relationship does still infinitely expand (on only one side - we were erroneously flagging both sides are infinitely expanding - unknown[] definitely doesn't infinitely expand!).

@weswigham
Copy link
Member Author

@ahejlsberg if you could take a look at this when you get a chance, that'd be great, thanks!

@sandersn sandersn added this to Not started in PR Backlog Dec 15, 2020
@sandersn sandersn moved this from Not started to Needs review in PR Backlog Dec 18, 2020
@andrewbranch
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 2, 2021

Heya @andrewbranch, I've started to run the tarball bundle task on this PR at b81c98b. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 2, 2021

Hey @andrewbranch, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/99984/artifacts?artifactName=tgz&fileId=BA6155E5AC16E3841FC2590B94FF87B9E10A9C49C2E9014AAB9A952942AB22E702&fileName=/typescript-4.3.0-insiders.20210402.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@4.3.0-pr-41821-3".;

@amcasey
Copy link
Member

amcasey commented Apr 20, 2021

@weswigham What's happening with this?

@weswigham
Copy link
Member Author

There's another issue this fixes -

function f1<T, K1 extends keyof T, K2 extends keyof T[K1]>(
    x: T[K1][K2], y: Extract<T[K1][K2], string>) {
    x = y;
    y = x; // missing error
}

// for comparison, the equivalent comparison with bare, unconstrained type parameters
function f2<T>(x: T, y: Extract<T, string>) {
    x = y;
    y = x; // correctly has error
}

decomposing T[K1][K2] to its base constraint takes > 5 steps, so without this change, hits our limiter and throws up a Maybe, which makes the comparison succeed.

@ahejlsberg it'd be super nice if you could review this ❤️

@ahejlsberg
Copy link
Member

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2021

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

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..41821

Metric master 41821 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 345,228k (± 0.01%) 345,203k (± 0.02%) -25k (- 0.01%) 345,069k 345,435k
Parse Time 1.92s (± 0.59%) 1.93s (± 0.67%) +0.01s (+ 0.62%) 1.90s 1.96s
Bind Time 0.84s (± 0.74%) 0.85s (± 0.35%) +0.01s (+ 1.07%) 0.84s 0.85s
Check Time 5.28s (± 0.30%) 5.32s (± 0.34%) +0.04s (+ 0.76%) 5.28s 5.35s
Emit Time 5.54s (± 0.49%) 5.66s (± 1.02%) +0.12s (+ 2.15%) 5.56s 5.84s
Total Time 13.58s (± 0.22%) 13.76s (± 0.45%) +0.18s (+ 1.32%) 13.63s 13.92s
Compiler-Unions - node (v10.16.3, x64)
Memory used 200,338k (± 0.06%) 200,312k (± 0.06%) -26k (- 0.01%) 199,920k 200,541k
Parse Time 0.78s (± 0.67%) 0.78s (± 0.57%) +0.00s (+ 0.39%) 0.77s 0.79s
Bind Time 0.53s (± 0.76%) 0.53s (± 0.98%) +0.00s (+ 0.38%) 0.52s 0.54s
Check Time 7.54s (± 0.45%) 7.57s (± 0.66%) +0.03s (+ 0.36%) 7.43s 7.65s
Emit Time 2.25s (± 1.16%) 2.47s (± 0.71%) +0.22s (+ 9.92%) 2.43s 2.51s
Total Time 11.10s (± 0.56%) 11.35s (± 0.40%) +0.25s (+ 2.29%) 11.22s 11.43s
Monaco - node (v10.16.3, x64)
Memory used 341,735k (± 0.01%) 341,648k (± 0.01%) -87k (- 0.03%) 341,534k 341,727k
Parse Time 1.55s (± 0.65%) 1.56s (± 1.17%) +0.01s (+ 0.39%) 1.50s 1.59s
Bind Time 0.74s (± 0.49%) 0.74s (± 0.80%) -0.00s (- 0.00%) 0.73s 0.76s
Check Time 5.40s (± 0.42%) 5.40s (± 0.41%) +0.00s (+ 0.00%) 5.37s 5.47s
Emit Time 3.00s (± 1.15%) 2.97s (± 0.89%) -0.03s (- 0.93%) 2.92s 3.05s
Total Time 10.69s (± 0.47%) 10.67s (± 0.49%) -0.02s (- 0.18%) 10.61s 10.84s
TFS - node (v10.16.3, x64)
Memory used 304,221k (± 0.03%) 304,253k (± 0.02%) +31k (+ 0.01%) 304,121k 304,399k
Parse Time 1.21s (± 0.39%) 1.22s (± 0.56%) +0.00s (+ 0.25%) 1.20s 1.23s
Bind Time 0.70s (± 0.85%) 0.71s (± 0.82%) +0.00s (+ 0.28%) 0.69s 0.72s
Check Time 4.87s (± 0.35%) 4.89s (± 0.59%) +0.01s (+ 0.27%) 4.81s 4.93s
Emit Time 3.09s (± 0.99%) 3.12s (± 1.15%) +0.04s (+ 1.20%) 3.07s 3.22s
Total Time 9.88s (± 0.40%) 9.93s (± 0.52%) +0.06s (+ 0.56%) 9.84s 10.08s
material-ui - node (v10.16.3, x64)
Memory used 474,033k (± 0.02%) 473,972k (± 0.02%) -61k (- 0.01%) 473,802k 474,154k
Parse Time 1.94s (± 0.57%) 1.95s (± 0.85%) +0.00s (+ 0.21%) 1.92s 1.98s
Bind Time 0.66s (± 1.45%) 0.66s (± 0.98%) +0.00s (+ 0.30%) 0.64s 0.67s
Check Time 14.30s (± 0.71%) 14.25s (± 0.78%) -0.05s (- 0.35%) 14.09s 14.48s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.90s (± 0.62%) 16.85s (± 0.70%) -0.05s (- 0.27%) 16.69s 17.10s
Angular - node (v12.1.0, x64)
Memory used 322,701k (± 0.02%) 322,743k (± 0.02%) +42k (+ 0.01%) 322,619k 322,906k
Parse Time 1.91s (± 0.41%) 1.91s (± 0.53%) +0.00s (+ 0.10%) 1.89s 1.93s
Bind Time 0.82s (± 0.63%) 0.83s (± 0.54%) +0.01s (+ 1.59%) 0.82s 0.84s
Check Time 5.16s (± 0.54%) 5.20s (± 0.65%) +0.05s (+ 0.89%) 5.13s 5.31s
Emit Time 5.76s (± 0.48%) 5.80s (± 0.86%) +0.04s (+ 0.64%) 5.72s 5.94s
Total Time 13.65s (± 0.37%) 13.75s (± 0.61%) +0.10s (+ 0.73%) 13.60s 14.02s
Compiler-Unions - node (v12.1.0, x64)
Memory used 187,815k (± 0.02%) 187,490k (± 0.16%) -325k (- 0.17%) 186,876k 188,074k
Parse Time 0.77s (± 0.78%) 0.77s (± 0.75%) +0.01s (+ 0.91%) 0.76s 0.79s
Bind Time 0.53s (± 0.69%) 0.54s (± 0.93%) +0.01s (+ 1.71%) 0.52s 0.54s
Check Time 7.00s (± 0.38%) 7.06s (± 0.55%) +0.06s (+ 0.86%) 6.99s 7.15s
Emit Time 2.25s (± 1.46%) 2.43s (± 1.27%) +0.18s (+ 7.86%) 2.37s 2.52s
Total Time 10.55s (± 0.45%) 10.80s (± 0.49%) +0.25s (+ 2.38%) 10.71s 10.92s
Monaco - node (v12.1.0, x64)
Memory used 323,851k (± 0.08%) 324,099k (± 0.01%) +248k (+ 0.08%) 324,000k 324,170k
Parse Time 1.54s (± 0.65%) 1.54s (± 0.84%) +0.01s (+ 0.39%) 1.52s 1.57s
Bind Time 0.72s (± 0.72%) 0.72s (± 0.62%) -0.00s (- 0.14%) 0.71s 0.73s
Check Time 5.24s (± 0.78%) 5.24s (± 0.59%) +0.00s (+ 0.04%) 5.19s 5.33s
Emit Time 3.05s (± 1.02%) 3.06s (± 0.71%) +0.01s (+ 0.20%) 3.02s 3.13s
Total Time 10.54s (± 0.67%) 10.56s (± 0.47%) +0.02s (+ 0.15%) 10.49s 10.68s
TFS - node (v12.1.0, x64)
Memory used 288,741k (± 0.02%) 288,779k (± 0.02%) +38k (+ 0.01%) 288,603k 288,919k
Parse Time 1.21s (± 0.84%) 1.22s (± 0.60%) +0.01s (+ 0.91%) 1.21s 1.24s
Bind Time 0.70s (± 0.71%) 0.70s (± 0.98%) 0.00s ( 0.00%) 0.68s 0.71s
Check Time 4.78s (± 0.50%) 4.80s (± 0.49%) +0.02s (+ 0.46%) 4.76s 4.87s
Emit Time 3.13s (± 0.65%) 3.12s (± 0.60%) -0.00s (- 0.00%) 3.09s 3.17s
Total Time 9.81s (± 0.47%) 9.84s (± 0.24%) +0.03s (+ 0.33%) 9.79s 9.90s
material-ui - node (v12.1.0, x64)
Memory used 451,611k (± 0.10%) 451,925k (± 0.02%) +314k (+ 0.07%) 451,658k 452,162k
Parse Time 1.95s (± 0.45%) 1.95s (± 0.50%) -0.00s (- 0.05%) 1.93s 1.97s
Bind Time 0.64s (± 0.73%) 0.64s (± 0.96%) +0.00s (+ 0.16%) 0.63s 0.66s
Check Time 12.89s (± 0.80%) 12.80s (± 0.69%) -0.09s (- 0.70%) 12.63s 13.09s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.48s (± 0.71%) 15.39s (± 0.56%) -0.09s (- 0.57%) 15.23s 15.68s
Angular - node (v14.15.1, x64)
Memory used 321,427k (± 0.01%) 321,303k (± 0.08%) -124k (- 0.04%) 320,319k 321,462k
Parse Time 1.91s (± 0.55%) 1.91s (± 0.79%) +0.00s (+ 0.10%) 1.88s 1.95s
Bind Time 0.87s (± 0.60%) 0.87s (± 0.56%) +0.00s (+ 0.58%) 0.86s 0.88s
Check Time 5.16s (± 0.46%) 5.20s (± 0.48%) +0.04s (+ 0.79%) 5.16s 5.25s
Emit Time 5.82s (± 0.51%) 5.87s (± 0.78%) +0.05s (+ 0.91%) 5.79s 5.97s
Total Time 13.76s (± 0.36%) 13.85s (± 0.41%) +0.10s (+ 0.72%) 13.71s 13.97s
Compiler-Unions - node (v14.15.1, x64)
Memory used 188,108k (± 0.63%) 188,115k (± 0.64%) +7k (+ 0.00%) 186,447k 189,765k
Parse Time 0.80s (± 0.72%) 0.80s (± 0.83%) -0.00s (- 0.00%) 0.79s 0.82s
Bind Time 0.56s (± 0.85%) 0.56s (± 1.03%) +0.01s (+ 1.08%) 0.55s 0.57s
Check Time 7.14s (± 0.54%) 7.16s (± 0.52%) +0.02s (+ 0.27%) 7.10s 7.23s
Emit Time 2.24s (± 0.90%) 2.44s (± 0.68%) +0.20s (+ 8.87%) 2.40s 2.49s
Total Time 10.74s (± 0.36%) 10.97s (± 0.41%) +0.22s (+ 2.08%) 10.89s 11.07s
Monaco - node (v14.15.1, x64)
Memory used 323,139k (± 0.01%) 323,134k (± 0.01%) -5k (- 0.00%) 323,086k 323,160k
Parse Time 1.57s (± 0.82%) 1.57s (± 0.60%) -0.01s (- 0.38%) 1.55s 1.59s
Bind Time 0.75s (± 0.78%) 0.75s (± 0.44%) +0.00s (+ 0.40%) 0.74s 0.76s
Check Time 5.21s (± 0.71%) 5.22s (± 0.46%) +0.01s (+ 0.13%) 5.16s 5.28s
Emit Time 3.09s (± 1.01%) 3.07s (± 0.71%) -0.02s (- 0.65%) 3.01s 3.12s
Total Time 10.62s (± 0.43%) 10.60s (± 0.33%) -0.02s (- 0.17%) 10.54s 10.68s
TFS - node (v14.15.1, x64)
Memory used 287,683k (± 0.01%) 287,668k (± 0.01%) -14k (- 0.00%) 287,634k 287,712k
Parse Time 1.27s (± 1.58%) 1.28s (± 0.83%) +0.00s (+ 0.31%) 1.25s 1.30s
Bind Time 0.71s (± 0.83%) 0.73s (± 1.60%) +0.01s (+ 1.68%) 0.71s 0.77s
Check Time 4.82s (± 0.33%) 4.80s (± 0.46%) -0.01s (- 0.29%) 4.75s 4.84s
Emit Time 3.21s (± 0.85%) 3.21s (± 0.72%) 0.00s ( 0.00%) 3.17s 3.28s
Total Time 10.01s (± 0.37%) 10.02s (± 0.35%) +0.00s (+ 0.03%) 9.96s 10.10s
material-ui - node (v14.15.1, x64)
Memory used 450,052k (± 0.07%) 450,117k (± 0.01%) +65k (+ 0.01%) 450,060k 450,178k
Parse Time 1.98s (± 0.61%) 2.00s (± 0.55%) +0.02s (+ 1.16%) 1.98s 2.03s
Bind Time 0.70s (± 0.82%) 0.70s (± 0.84%) +0.00s (+ 0.57%) 0.69s 0.72s
Check Time 12.99s (± 0.64%) 12.99s (± 0.46%) -0.00s (- 0.04%) 12.90s 13.10s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.67s (± 0.56%) 15.69s (± 0.40%) +0.02s (+ 0.11%) 15.60s 15.82s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-206-generic
Architecturex64
Available Memory16 GB
Available Memory2 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
Benchmark Name Iterations
Current 41821 10
Baseline master 10

Developer Information:

Download Benchmark

@ahejlsberg
Copy link
Member

What if one of the sides has a constraint that keeps on generating deeper and deeper types? Won't we just keep on going and eventually hit the 100 level panic limiter and issue an error? Is that what we want?

@weswigham
Copy link
Member Author

I think it is - a generative type should probably hit the issues-an-error limiter and not the quietly-pass-assignability limiter.

@ahejlsberg
Copy link
Member

Hmm. But it just seems really odd that we would issue an error if nothing changes one one side, but if that side instead flip-flops between two types, then all of a sudden we're fine with it (because we produce a Ternary.Maybe).

@ahejlsberg
Copy link
Member

In other words, our limiter is based on the notion that we count occurrences of cycles, and all of a sudden we're saying that a cycle of length one doesn't count at all. I'm not sure I can make that make sense.

@weswigham
Copy link
Member Author

weswigham commented May 19, 2021

Hmm. But it just seems really odd that we would issue an error if nothing changes one one side, but if that side instead flip-flops between two types, then all of a sudden we're fine with it (because we produce a Ternary.Maybe).

In such a case, we never get to check the one side that "didn't change" precisely because the other side decomposed forever. That's exactly why it makes sense to issue an error - we never even got to look at the rhs because the lhs was expanding forever. If both the lhs and rhs expand forever, we'll still issue an error, because the lhs expanding forever will prevent us from even checking that the rhs expands forever. "This type expands forever" is a very distinct problem from "this type depends on a comparison which occurred in its history already" - the first we don't really have a reasonable operation to do (blindly allowing the assignment to anything isn't good - we're not even looking at the target!), while for the second, a Ternary.Maybe result (as a non-caching True, since we can assume a comparison in progress is a success while looking to disprove that) allows the comparison to continue on the other parts of the type structure.

if that side instead flip-flops between two types, then all of a sudden we're fine with it (because we produce a Ternary.Maybe).

Specifically, I think this is at least more justifiable, since then we've actually explored some structure on both sides, we just want to refrain from exploring too deeply. Whereas when we only ever explore how one side of the relationship expands, it's very hard to justify the assignment (why should a T[A][B] function as a never on the source side and be assignable to anything just because it's deeply generic? Meanwhile if we compare T[A][B] to U[C][D] we're more within our rights, imo, to just give up and say "it's too deeply generic on both sides and we don't wanna exhaustively explore this - just let it pass (unless a less nested check we have available fails)").

In other words, our limiter is based on the notion that we count occurrences of cycles, and all of a sudden we're saying that a cycle of length one doesn't count at all. I'm not sure I can make that make sense.

Except it's not actually counting cycles because it has no knowledge of which side of the comparison (if any) was actually recurred on to produce the new pair of types, which is what it'd need to count that (specifically, it'd only check if the side we recurred on is deeply nested). What we're tracking right now is just occurrences in history, which doesn't correctly admit, say, the LHS looping forever while the RHS just sits there uninspected because we have yet to recur on it (which is turns out is very common, as pretty simple LHS constructs end up taking more than 5 steps to expand to a final constraint!)

Ideally, we'd only append to the sourceStack/targetStack when that side of the relationship is recurred on, but that would require threading more information through every recursive call of isRelatedTo. Maybe the intersectionState parameter could be hijacked to traffic this, but it probably wouldn't be pretty. Only appending an element when it changes is a decent approximation since we generally try very hard to not recur on a type and immediately produce the same comparison - generally speaking, we like to have every decomposition we perform change the type we decompose in some way, or we don't attempt the decomposition at all (specifically, we don't let a generic be directly constrained to itself - that's an error - it has to go through some cycle of deferred decompositions instead, which, under this scheme, will always result in new entries into the stack, and thus for a cycle to be detected).

@ahejlsberg
Copy link
Member

Let's run the tests to get some more real world data on what the effect is.

@ahejlsberg
Copy link
Member

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2021

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

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..41821

Metric main 41821 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 351,004k (± 0.02%) 351,060k (± 0.02%) +56k (+ 0.02%) 350,878k 351,287k
Parse Time 1.90s (± 0.52%) 1.91s (± 0.36%) +0.01s (+ 0.42%) 1.90s 1.93s
Bind Time 0.86s (± 0.75%) 0.87s (± 0.69%) +0.00s (+ 0.46%) 0.85s 0.88s
Check Time 5.37s (± 0.60%) 5.38s (± 0.58%) +0.02s (+ 0.30%) 5.33s 5.47s
Emit Time 5.82s (± 0.66%) 5.85s (± 0.82%) +0.03s (+ 0.57%) 5.75s 5.95s
Total Time 13.95s (± 0.37%) 14.00s (± 0.37%) +0.05s (+ 0.39%) 13.88s 14.14s
Compiler-Unions - node (v10.16.3, x64)
Memory used 203,395k (± 0.03%) 203,447k (± 0.03%) +52k (+ 0.03%) 203,308k 203,619k
Parse Time 0.78s (± 0.63%) 0.79s (± 0.87%) +0.00s (+ 0.26%) 0.77s 0.80s
Bind Time 0.53s (± 1.27%) 0.53s (± 0.90%) +0.00s (+ 0.00%) 0.52s 0.54s
Check Time 7.83s (± 0.84%) 7.83s (± 0.69%) -0.00s (- 0.01%) 7.75s 8.02s
Emit Time 2.44s (± 1.09%) 2.43s (± 0.87%) -0.01s (- 0.41%) 2.40s 2.48s
Total Time 11.58s (± 0.72%) 11.57s (± 0.63%) -0.01s (- 0.06%) 11.47s 11.83s
Monaco - node (v10.16.3, x64)
Memory used 340,578k (± 0.02%) 340,660k (± 0.03%) +83k (+ 0.02%) 340,516k 340,992k
Parse Time 1.46s (± 0.55%) 1.46s (± 0.48%) -0.00s (- 0.21%) 1.45s 1.48s
Bind Time 0.75s (± 0.82%) 0.75s (± 0.46%) -0.00s (- 0.27%) 0.74s 0.75s
Check Time 5.42s (± 0.54%) 5.42s (± 0.69%) +0.00s (+ 0.00%) 5.32s 5.50s
Emit Time 3.16s (± 0.70%) 3.16s (± 0.99%) -0.00s (- 0.09%) 3.11s 3.23s
Total Time 10.79s (± 0.39%) 10.78s (± 0.52%) -0.01s (- 0.07%) 10.70s 10.91s
TFS - node (v10.16.3, x64)
Memory used 304,033k (± 0.02%) 304,057k (± 0.02%) +23k (+ 0.01%) 303,932k 304,169k
Parse Time 1.19s (± 0.50%) 1.19s (± 0.74%) +0.00s (+ 0.08%) 1.17s 1.21s
Bind Time 0.71s (± 0.78%) 0.71s (± 0.69%) +0.00s (+ 0.28%) 0.70s 0.72s
Check Time 4.91s (± 0.42%) 4.92s (± 0.78%) +0.01s (+ 0.24%) 4.86s 5.02s
Emit Time 3.34s (± 1.15%) 3.34s (± 1.11%) -0.01s (- 0.21%) 3.27s 3.45s
Total Time 10.15s (± 0.44%) 10.16s (± 0.72%) +0.01s (+ 0.10%) 10.03s 10.34s
material-ui - node (v10.16.3, x64)
Memory used 469,707k (± 0.01%) 469,737k (± 0.01%) +30k (+ 0.01%) 469,679k 469,877k
Parse Time 1.73s (± 0.39%) 1.73s (± 0.80%) -0.00s (- 0.29%) 1.69s 1.77s
Bind Time 0.66s (± 0.74%) 0.67s (± 1.52%) +0.00s (+ 0.15%) 0.63s 0.68s
Check Time 14.22s (± 0.58%) 14.14s (± 0.55%) -0.09s (- 0.60%) 13.99s 14.35s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.63s (± 0.51%) 16.53s (± 0.46%) -0.09s (- 0.56%) 16.39s 16.74s
Angular - node (v12.1.0, x64)
Memory used 328,871k (± 0.08%) 329,010k (± 0.03%) +139k (+ 0.04%) 328,872k 329,210k
Parse Time 1.87s (± 0.43%) 1.87s (± 0.36%) +0.00s (+ 0.11%) 1.86s 1.88s
Bind Time 0.85s (± 0.96%) 0.84s (± 0.66%) -0.00s (- 0.59%) 0.83s 0.85s
Check Time 5.22s (± 0.66%) 5.21s (± 0.38%) -0.01s (- 0.23%) 5.17s 5.26s
Emit Time 6.07s (± 0.72%) 6.09s (± 0.72%) +0.02s (+ 0.31%) 6.02s 6.19s
Total Time 14.00s (± 0.51%) 14.01s (± 0.40%) +0.01s (+ 0.04%) 13.92s 14.12s
Compiler-Unions - node (v12.1.0, x64)
Memory used 190,766k (± 0.13%) 190,849k (± 0.10%) +83k (+ 0.04%) 190,367k 191,081k
Parse Time 0.78s (± 0.79%) 0.78s (± 0.79%) +0.00s (+ 0.00%) 0.77s 0.79s
Bind Time 0.53s (± 0.75%) 0.53s (± 0.84%) +0.00s (+ 0.19%) 0.52s 0.54s
Check Time 7.35s (± 1.26%) 7.28s (± 0.64%) -0.07s (- 1.02%) 7.21s 7.43s
Emit Time 2.42s (± 0.37%) 2.43s (± 0.75%) +0.01s (+ 0.37%) 2.41s 2.48s
Total Time 11.09s (± 0.86%) 11.02s (± 0.50%) -0.06s (- 0.56%) 10.95s 11.16s
Monaco - node (v12.1.0, x64)
Memory used 323,760k (± 0.06%) 323,760k (± 0.02%) +1k (+ 0.00%) 323,627k 323,977k
Parse Time 1.42s (± 0.71%) 1.43s (± 0.65%) +0.01s (+ 0.49%) 1.41s 1.45s
Bind Time 0.72s (± 0.90%) 0.73s (± 0.65%) +0.01s (+ 0.69%) 0.72s 0.74s
Check Time 5.23s (± 0.58%) 5.26s (± 0.54%) +0.03s (+ 0.59%) 5.20s 5.32s
Emit Time 3.19s (± 0.78%) 3.19s (± 0.89%) -0.01s (- 0.25%) 3.14s 3.26s
Total Time 10.57s (± 0.41%) 10.61s (± 0.47%) +0.04s (+ 0.34%) 10.51s 10.74s
TFS - node (v12.1.0, x64)
Memory used 288,731k (± 0.02%) 288,775k (± 0.03%) +43k (+ 0.02%) 288,577k 288,962k
Parse Time 1.20s (± 0.72%) 1.20s (± 0.58%) +0.00s (+ 0.25%) 1.19s 1.22s
Bind Time 0.70s (± 0.74%) 0.70s (± 1.27%) +0.01s (+ 0.86%) 0.69s 0.73s
Check Time 4.82s (± 0.30%) 4.84s (± 0.38%) +0.02s (+ 0.41%) 4.79s 4.89s
Emit Time 3.34s (± 1.11%) 3.38s (± 0.77%) +0.04s (+ 1.14%) 3.30s 3.42s
Total Time 10.06s (± 0.44%) 10.12s (± 0.41%) +0.07s (+ 0.68%) 10.07s 10.26s
material-ui - node (v12.1.0, x64)
Memory used 448,522k (± 0.01%) 448,300k (± 0.08%) -222k (- 0.05%) 447,280k 448,668k
Parse Time 1.72s (± 0.62%) 1.72s (± 0.93%) +0.00s (+ 0.06%) 1.69s 1.76s
Bind Time 0.65s (± 1.02%) 0.65s (± 0.80%) +0.00s (+ 0.15%) 0.64s 0.66s
Check Time 12.76s (± 0.72%) 12.78s (± 0.82%) +0.02s (+ 0.16%) 12.57s 13.02s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.13s (± 0.59%) 15.15s (± 0.67%) +0.02s (+ 0.15%) 14.96s 15.37s
Angular - node (v14.15.1, x64)
Memory used 327,621k (± 0.00%) 327,619k (± 0.01%) -1k (- 0.00%) 327,558k 327,683k
Parse Time 1.90s (± 0.62%) 1.90s (± 0.57%) 0.00s ( 0.00%) 1.88s 1.93s
Bind Time 0.89s (± 0.50%) 0.89s (± 0.56%) -0.00s (- 0.34%) 0.88s 0.90s
Check Time 5.26s (± 0.71%) 5.25s (± 0.51%) -0.01s (- 0.29%) 5.19s 5.30s
Emit Time 6.15s (± 0.48%) 6.14s (± 0.88%) -0.01s (- 0.23%) 6.03s 6.25s
Total Time 14.21s (± 0.35%) 14.18s (± 0.52%) -0.03s (- 0.21%) 14.01s 14.31s
Compiler-Unions - node (v14.15.1, x64)
Memory used 191,477k (± 0.60%) 191,482k (± 0.59%) +5k (+ 0.00%) 189,612k 192,806k
Parse Time 0.81s (± 0.82%) 0.80s (± 0.61%) -0.01s (- 0.74%) 0.80s 0.82s
Bind Time 0.56s (± 0.00%) 0.56s (± 0.72%) -0.00s (- 0.18%) 0.55s 0.57s
Check Time 7.50s (± 0.56%) 7.52s (± 0.69%) +0.02s (+ 0.24%) 7.38s 7.63s
Emit Time 2.42s (± 0.55%) 2.42s (± 0.56%) +0.00s (+ 0.17%) 2.39s 2.45s
Total Time 11.29s (± 0.39%) 11.31s (± 0.51%) +0.01s (+ 0.12%) 11.16s 11.44s
Monaco - node (v14.15.1, x64)
Memory used 322,567k (± 0.00%) 322,563k (± 0.00%) -4k (- 0.00%) 322,535k 322,608k
Parse Time 1.48s (± 0.51%) 1.49s (± 0.68%) +0.00s (+ 0.13%) 1.47s 1.52s
Bind Time 0.75s (± 0.45%) 0.75s (± 0.65%) +0.00s (+ 0.13%) 0.75s 0.77s
Check Time 5.21s (± 0.35%) 5.24s (± 0.60%) +0.03s (+ 0.56%) 5.16s 5.30s
Emit Time 3.23s (± 0.54%) 3.22s (± 0.91%) -0.01s (- 0.31%) 3.17s 3.29s
Total Time 10.68s (± 0.28%) 10.70s (± 0.48%) +0.02s (+ 0.19%) 10.59s 10.81s
TFS - node (v14.15.1, x64)
Memory used 287,720k (± 0.00%) 287,715k (± 0.01%) -5k (- 0.00%) 287,687k 287,756k
Parse Time 1.25s (± 1.57%) 1.23s (± 1.23%) -0.02s (- 1.28%) 1.20s 1.26s
Bind Time 0.73s (± 3.16%) 0.77s (± 5.28%) +0.04s (+ 5.88%) 0.71s 0.88s
Check Time 4.85s (± 0.63%) 4.87s (± 0.60%) +0.02s (+ 0.43%) 4.81s 4.93s
Emit Time 3.46s (± 0.70%) 3.45s (± 0.88%) -0.00s (- 0.06%) 3.41s 3.56s
Total Time 10.29s (± 0.50%) 10.33s (± 0.55%) +0.04s (+ 0.43%) 10.18s 10.43s
material-ui - node (v14.15.1, x64)
Memory used 446,740k (± 0.06%) 446,884k (± 0.01%) +145k (+ 0.03%) 446,813k 446,926k
Parse Time 1.76s (± 0.61%) 1.76s (± 0.54%) -0.00s (- 0.17%) 1.74s 1.77s
Bind Time 0.69s (± 0.75%) 0.69s (± 0.72%) -0.00s (- 0.44%) 0.68s 0.70s
Check Time 13.10s (± 1.28%) 12.86s (± 1.05%) -0.24s (- 1.82%) 12.72s 13.38s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.55s (± 1.09%) 15.31s (± 0.89%) -0.25s (- 1.58%) 15.15s 15.83s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-206-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 (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
Benchmark Name Iterations
Current 41821 10
Baseline main 10

Developer Information:

Download Benchmark

@weswigham
Copy link
Member Author

@typescript-bot pack this for posterity

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 20, 2021

Heya @weswigham, I've started to run the tarball bundle task on this PR at f76d880. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 20, 2021

Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/109006/artifacts?artifactName=tgz&fileId=32F14BC1CCCC5B6DD6C83299C9148D3BA148907CCB93F5D7064C29EF2F37E2A902&fileName=/typescript-4.5.0-insiders.20210820.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@4.5.0-pr-41821-43".;

@weswigham
Copy link
Member Author

All extended test suites (RWC, user, DT) look good. Let me try to remove the extra isDeeplyNestedType calls and give em another go - if they stay green we'll go with that, otherwise I'll revert that and go with this~

@weswigham
Copy link
Member Author

Nope, scratch that - local tests fail if we remove them - the depth check guards are needed on the comparison of conditional constraints, otherwise we issue stack depth warnings when comparing conditional types that operate over recursive type aliases (rather than only erroring when their actual execution exceeds the instantiation limit). We need 'em so we stop recurring further into the (infinitely expanding) type, and instead gracefully try a different constraint form (eg, the distributive constraint instead of the non-distributive one, or vice-versa).

So this should be good to go as-is. @ahejlsberg anything else to add?

@fabb
Copy link

fabb commented Aug 23, 2021

Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/109006/artifacts?artifactName=tgz&fileId=32F14BC1CCCC5B6DD6C83299C9148D3BA148907CCB93F5D7064C29EF2F37E2A902&fileName=/typescript-4.5.0-insiders.20210820.tgz"
    }
}

and then running npm install.

There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@4.5.0-pr-41821-43".;

This version still does not fix the issue for my case: #44404 (comment)

@@ -18868,7 +18891,7 @@ namespace ts {
else {
targetKeys = nameType || constraintType;
}
if (isRelatedTo(source, targetKeys, reportErrors) === Ternary.True) {
if (isRelatedTo(source, targetKeys, RecursionFlags.Target, reportErrors) === Ternary.True) {
Copy link
Member

Choose a reason for hiding this comment

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

I added this one while resolving merge conflicts

@andrewbranch
Copy link
Member

Apparently I didn’t pull recently enough to resolve all the conflicts 🤦

PR Backlog automation moved this from Waiting on reviewers to Needs merge Sep 30, 2021
@andrewbranch andrewbranch merged commit 612c92d into microsoft:main Sep 30, 2021
PR Backlog automation moved this from Needs merge to Done Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
PR Backlog
  
Done
6 participants