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

@@ -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

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

@weswigham weswigham commented Dec 4, 2020

@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

@andrewbranch andrewbranch commented Apr 2, 2021

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

@typescript-bot 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 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 amcasey commented Apr 20, 2021

@weswigham What's happening with this?

@weswigham
Copy link
Member Author

@weswigham weswigham commented May 14, 2021

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

@ahejlsberg ahejlsberg commented May 19, 2021

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

@typescript-bot 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

@typescript-bot typescript-bot commented May 19, 2021

@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

@ahejlsberg ahejlsberg commented May 19, 2021

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

@weswigham weswigham commented May 19, 2021

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

@ahejlsberg ahejlsberg 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).

@ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented May 19, 2021

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

@ahejlsberg ahejlsberg commented May 19, 2021

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

@ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented May 19, 2021

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

@typescript-bot
Copy link
Collaborator

@typescript-bot 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

@typescript-bot typescript-bot commented Jul 28, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Jul 28, 2021

@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 347,541k (± 0.03%) 347,527k (± 0.03%) -14k (- 0.00%) 347,296k 347,730k
Parse Time 1.88s (± 0.46%) 1.89s (± 0.51%) +0.01s (+ 0.48%) 1.86s 1.91s
Bind Time 0.86s (± 0.52%) 0.86s (± 0.90%) +0.00s (+ 0.12%) 0.84s 0.88s
Check Time 5.34s (± 0.39%) 5.35s (± 0.36%) +0.02s (+ 0.34%) 5.32s 5.40s
Emit Time 5.82s (± 0.47%) 5.82s (± 0.47%) +0.00s (+ 0.07%) 5.74s 5.86s
Total Time 13.89s (± 0.21%) 13.92s (± 0.36%) +0.03s (+ 0.22%) 13.76s 13.99s
Compiler-Unions - node (v10.16.3, x64)
Memory used 203,318k (± 0.03%) 203,421k (± 0.03%) +104k (+ 0.05%) 203,265k 203,533k
Parse Time 0.79s (± 0.60%) 0.78s (± 0.97%) -0.00s (- 0.38%) 0.77s 0.80s
Bind Time 0.53s (± 1.45%) 0.52s (± 1.24%) -0.00s (- 0.57%) 0.51s 0.54s
Check Time 7.77s (± 0.42%) 7.83s (± 0.77%) +0.06s (+ 0.75%) 7.69s 7.94s
Emit Time 2.44s (± 0.83%) 2.44s (± 0.83%) +0.01s (+ 0.25%) 2.40s 2.49s
Total Time 11.51s (± 0.40%) 11.58s (± 0.64%) +0.06s (+ 0.55%) 11.42s 11.72s
Monaco - node (v10.16.3, x64)
Memory used 340,616k (± 0.04%) 340,556k (± 0.01%) -60k (- 0.02%) 340,435k 340,619k
Parse Time 1.47s (± 0.48%) 1.46s (± 0.68%) -0.01s (- 0.75%) 1.43s 1.48s
Bind Time 0.74s (± 0.64%) 0.75s (± 0.63%) +0.01s (+ 0.94%) 0.74s 0.76s
Check Time 5.41s (± 0.68%) 5.36s (± 0.59%) -0.05s (- 0.91%) 5.27s 5.41s
Emit Time 3.16s (± 0.60%) 3.14s (± 0.93%) -0.02s (- 0.57%) 3.11s 3.24s
Total Time 10.78s (± 0.48%) 10.71s (± 0.12%) -0.07s (- 0.66%) 10.67s 10.73s
TFS - node (v10.16.3, x64)
Memory used 303,972k (± 0.02%) 303,946k (± 0.03%) -26k (- 0.01%) 303,774k 304,098k
Parse Time 1.18s (± 0.38%) 1.18s (± 0.31%) +0.00s (+ 0.25%) 1.18s 1.19s
Bind Time 0.71s (± 1.03%) 0.72s (± 0.83%) +0.01s (+ 1.13%) 0.70s 0.73s
Check Time 4.88s (± 0.41%) 4.90s (± 0.46%) +0.01s (+ 0.25%) 4.84s 4.94s
Emit Time 3.30s (± 1.31%) 3.34s (± 1.44%) +0.04s (+ 1.24%) 3.24s 3.45s
Total Time 10.07s (± 0.46%) 10.14s (± 0.65%) +0.06s (+ 0.64%) 10.02s 10.28s
material-ui - node (v10.16.3, x64)
Memory used 469,676k (± 0.01%) 469,704k (± 0.01%) +28k (+ 0.01%) 469,565k 469,903k
Parse Time 1.73s (± 0.50%) 1.73s (± 0.71%) -0.00s (- 0.00%) 1.71s 1.77s
Bind Time 0.67s (± 0.55%) 0.67s (± 0.87%) +0.00s (+ 0.15%) 0.65s 0.68s
Check Time 14.18s (± 0.47%) 14.13s (± 0.35%) -0.05s (- 0.39%) 14.00s 14.23s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.58s (± 0.39%) 16.52s (± 0.34%) -0.06s (- 0.34%) 16.39s 16.64s
Angular - node (v12.1.0, x64)
Memory used 325,473k (± 0.08%) 325,574k (± 0.02%) +102k (+ 0.03%) 325,443k 325,735k
Parse Time 1.85s (± 0.48%) 1.85s (± 0.63%) -0.00s (- 0.16%) 1.82s 1.87s
Bind Time 0.84s (± 0.35%) 0.84s (± 0.84%) +0.00s (+ 0.12%) 0.83s 0.86s
Check Time 5.18s (± 0.51%) 5.18s (± 0.46%) +0.00s (+ 0.04%) 5.13s 5.23s
Emit Time 6.04s (± 0.43%) 6.06s (± 1.00%) +0.02s (+ 0.35%) 5.99s 6.28s
Total Time 13.91s (± 0.34%) 13.93s (± 0.57%) +0.02s (+ 0.13%) 13.81s 14.21s
Compiler-Unions - node (v12.1.0, x64)
Memory used 190,627k (± 0.11%) 191,053k (± 0.31%) +426k (+ 0.22%) 190,122k 193,302k
Parse Time 0.77s (± 0.77%) 0.78s (± 0.75%) +0.00s (+ 0.26%) 0.77s 0.79s
Bind Time 0.54s (± 0.92%) 0.53s (± 0.42%) -0.01s (- 0.93%) 0.53s 0.54s
Check Time 7.28s (± 0.41%) 7.29s (± 0.44%) +0.01s (+ 0.12%) 7.24s 7.36s
Emit Time 2.44s (± 0.66%) 2.45s (± 0.77%) +0.01s (+ 0.33%) 2.41s 2.51s
Total Time 11.04s (± 0.32%) 11.05s (± 0.39%) +0.01s (+ 0.10%) 10.98s 11.14s
Monaco - node (v12.1.0, x64)
Memory used 323,687k (± 0.02%) 323,743k (± 0.03%) +56k (+ 0.02%) 323,592k 324,019k
Parse Time 1.42s (± 0.49%) 1.42s (± 0.39%) +0.00s (+ 0.21%) 1.41s 1.43s
Bind Time 0.72s (± 1.05%) 0.73s (± 0.92%) +0.00s (+ 0.28%) 0.71s 0.74s
Check Time 5.23s (± 0.50%) 5.24s (± 0.45%) +0.00s (+ 0.10%) 5.19s 5.28s
Emit Time 3.18s (± 1.15%) 3.17s (± 0.32%) -0.01s (- 0.25%) 3.15s 3.19s
Total Time 10.55s (± 0.51%) 10.55s (± 0.23%) +0.00s (+ 0.02%) 10.49s 10.59s
TFS - node (v12.1.0, x64)
Memory used 288,668k (± 0.02%) 288,643k (± 0.02%) -25k (- 0.01%) 288,423k 288,796k
Parse Time 1.20s (± 0.85%) 1.21s (± 0.56%) +0.01s (+ 0.42%) 1.19s 1.22s
Bind Time 0.70s (± 0.53%) 0.70s (± 1.19%) +0.00s (+ 0.14%) 0.68s 0.72s
Check Time 4.84s (± 0.72%) 4.82s (± 0.67%) -0.02s (- 0.33%) 4.77s 4.91s
Emit Time 3.37s (± 0.33%) 3.36s (± 0.97%) -0.01s (- 0.24%) 3.28s 3.43s
Total Time 10.11s (± 0.34%) 10.09s (± 0.62%) -0.02s (- 0.19%) 9.97s 10.23s
material-ui - node (v12.1.0, x64)
Memory used 448,428k (± 0.02%) 448,311k (± 0.07%) -117k (- 0.03%) 447,095k 448,559k
Parse Time 1.72s (± 0.55%) 1.71s (± 0.55%) -0.00s (- 0.12%) 1.70s 1.74s
Bind Time 0.65s (± 0.92%) 0.65s (± 0.77%) -0.00s (- 0.15%) 0.64s 0.66s
Check Time 12.67s (± 0.45%) 12.75s (± 0.65%) +0.07s (+ 0.59%) 12.63s 13.01s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.04s (± 0.36%) 15.11s (± 0.54%) +0.07s (+ 0.46%) 15.00s 15.35s
Angular - node (v14.15.1, x64)
Memory used 324,155k (± 0.01%) 324,134k (± 0.00%) -21k (- 0.01%) 324,092k 324,159k
Parse Time 1.87s (± 0.55%) 1.88s (± 0.59%) +0.01s (+ 0.37%) 1.86s 1.91s
Bind Time 0.89s (± 0.62%) 0.89s (± 0.69%) -0.00s (- 0.11%) 0.88s 0.91s
Check Time 5.21s (± 0.29%) 5.20s (± 0.30%) -0.01s (- 0.17%) 5.17s 5.24s
Emit Time 6.12s (± 0.77%) 6.15s (± 0.43%) +0.03s (+ 0.51%) 6.09s 6.22s
Total Time 14.09s (± 0.43%) 14.12s (± 0.22%) +0.03s (+ 0.21%) 14.05s 14.19s
Compiler-Unions - node (v14.15.1, x64)
Memory used 190,799k (± 0.61%) 190,501k (± 0.57%) -298k (- 0.16%) 189,492k 192,783k
Parse Time 0.80s (± 0.37%) 0.81s (± 0.59%) +0.01s (+ 0.62%) 0.80s 0.82s
Bind Time 0.56s (± 0.79%) 0.56s (± 0.53%) -0.00s (- 0.71%) 0.55s 0.56s
Check Time 7.43s (± 0.45%) 7.43s (± 0.35%) +0.00s (+ 0.03%) 7.40s 7.52s
Emit Time 2.41s (± 1.39%) 2.42s (± 0.88%) +0.01s (+ 0.41%) 2.39s 2.49s
Total Time 11.21s (± 0.39%) 11.22s (± 0.23%) +0.01s (+ 0.09%) 11.16s 11.29s
Monaco - node (v14.15.1, x64)
Memory used 322,493k (± 0.00%) 322,496k (± 0.00%) +3k (+ 0.00%) 322,471k 322,524k
Parse Time 1.49s (± 0.57%) 1.49s (± 0.60%) -0.01s (- 0.40%) 1.46s 1.50s
Bind Time 0.75s (± 0.63%) 0.75s (± 0.69%) +0.00s (+ 0.13%) 0.74s 0.77s
Check Time 5.19s (± 0.50%) 5.18s (± 0.45%) -0.02s (- 0.35%) 5.12s 5.23s
Emit Time 3.21s (± 0.67%) 3.20s (± 0.31%) -0.01s (- 0.25%) 3.19s 3.23s
Total Time 10.65s (± 0.36%) 10.62s (± 0.17%) -0.03s (- 0.29%) 10.57s 10.66s
TFS - node (v14.15.1, x64)
Memory used 287,672k (± 0.01%) 287,684k (± 0.01%) +12k (+ 0.00%) 287,649k 287,724k
Parse Time 1.25s (± 1.26%) 1.26s (± 1.77%) +0.01s (+ 0.64%) 1.20s 1.33s
Bind Time 0.72s (± 1.38%) 0.72s (± 1.01%) -0.00s (- 0.14%) 0.71s 0.74s
Check Time 4.83s (± 0.40%) 4.83s (± 0.51%) +0.00s (+ 0.04%) 4.76s 4.89s
Emit Time 3.45s (± 0.88%) 3.46s (± 0.92%) +0.00s (+ 0.09%) 3.40s 3.56s
Total Time 10.25s (± 0.41%) 10.26s (± 0.29%) +0.01s (+ 0.11%) 10.17s 10.32s
material-ui - node (v14.15.1, x64)
Memory used 446,836k (± 0.01%) 446,729k (± 0.06%) -107k (- 0.02%) 445,691k 446,897k
Parse Time 1.75s (± 0.25%) 1.75s (± 0.58%) +0.00s (+ 0.06%) 1.72s 1.77s
Bind Time 0.69s (± 0.87%) 0.69s (± 0.90%) +0.00s (+ 0.44%) 0.68s 0.70s
Check Time 12.90s (± 1.31%) 12.91s (± 0.63%) +0.01s (+ 0.06%) 12.73s 13.11s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.34s (± 1.11%) 15.35s (± 0.55%) +0.01s (+ 0.08%) 15.15s 15.56s
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

@ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented Aug 19, 2021

@weswigham I tried the PR on this example:

function f1<T, K1 extends keyof T, K2 extends keyof T[K1]>() {
    let v1: Extract<T, string> = 0 as any as T;  // Error
    let v2: Extract<T[K1], string> = 0 as any as T[K1];  // Error
    let v3: Extract<T[K1][K2], string> = 0 as any as T[K1][K2];  // No error
}

I was expecting an error on the last line, but I'm not seeing it. Any ideas?

overflow = true;
return Ternary.False;
}
}
const constantSource = sourceStack[sourceDepth] === source;
const constantTarget = targetStack[targetDepth] === target;
Copy link
Member

@ahejlsberg ahejlsberg Aug 19, 2021

This doesn't seem right. Only elements at indices less than sourceDepth and targetDepth have meaningful values. This appears to compare an effectively random value with source or target. Or am I missing something?

Copy link
Member

@ahejlsberg ahejlsberg Aug 19, 2021

Don't you need something like this?

const constantSource = sourceDepth > 0 && sourceStack[sourceDepth - 1] === source;
const constantTarget = targetDepth > 0 && targetStack[targetDepth - 1] === target;

@ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented Aug 19, 2021

When I fix the constantSource and constantTarget checks, the example with Extract<...> starts erroring as expected. But then we have this inconsistent behavior:

type Foo<T> = { x: Foo<T> };
type Bar<T> = { x: Bar<T[]> };

function f2<U>() {
    let x: Foo<U> = 0 as any as Bar<U>;  // Error, excessive stack depth
}

type Foo1<T> = { x: Foo2<T> };
type Foo2<T> = { x: Foo1<T> };

function f3<U>() {
    let x: Foo1<U> = 0 as any as Bar<U>;  // No error!
}

I'm not sure the approach of checking "constantness" on one side is going to work. I'm thinking a better approach is to pass a flag to isRelatedTo that disables the isDeeplyNestedType check and then use that flag in cases where we are exploring a constraint.

@weswigham
Copy link
Member Author

@weswigham weswigham commented Aug 20, 2021

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

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Aug 20, 2021

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

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Aug 20, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Aug 20, 2021

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

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Aug 20, 2021

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

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Aug 20, 2021

@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

@weswigham weswigham commented Aug 20, 2021

@typescript-bot pack this for posterity

@typescript-bot
Copy link
Collaborator

@typescript-bot 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 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

@weswigham weswigham commented Aug 20, 2021

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

@weswigham weswigham commented Aug 20, 2021

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

@andrewbranch andrewbranch Sep 30, 2021

I added this one while resolving merge conflicts

@andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Sep 30, 2021

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
10 checks passed
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