Skip to content

Allow inference to explore multiple instances of the same symbol #31633

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

Conversation

weswigham
Copy link
Member

Fixes #31616

Different instances of a type with a symbol are different instances, ergo can have different underlying structure and produce differing inferences. Stopping after we've seen a symbol once as we recur downward (but not once globally) is actually strange - it meant we'd infer to both instances in {a: Foo<A, M>, b: Foo<B, N>}, but to only one while checking {a: Foo<A, Foo<B, M>>}. The need for a limiter here makes sense (since we do produce types that can infinitely expand), but this one was excessively restrictive.

Additionally, for consistency (since it needs a similar cutoff), I've unified the depth limit constant between inference and type printout.

@weswigham
Copy link
Member Author

@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 28, 2019

Heya @weswigham, I've started to run the extended test suite on this PR at 58b71fe. You can monitor the build here. It should now contribute to this PR's status checks.

@weswigham
Copy link
Member Author

So, looking at fp-ts in our rwc suite, when maxSymbolRecusionDepth is 1, we compile in about 23 seconds. When maxSymbolRecusionDepth is 2 we compile in about 29 seconds. When maxSymbolRecusionDepth is >=3 we OOM. I'm given to believe that there is a specific pattern of construction used within fp-ts that happens to be 3 symbols deep when it triggers runaway pingponging between type inference and type creation which is why #15863 (which cutoff at depth 1) quelled it. From what I can tell, it's essentially that we're really naive when comparing None<A> and FantasyMonad<"Option", A> (and similar). When we're doing a relationship check, it's a given that we consider the thing we're comparing as true - however, in the process of structural checking we need to compare None<(x: A) => B> and FantasyMonad<"Option", (x: A) => B> - given that since we're already comparing None<A> and FantasyMonad<"Option", A>, this specialization of that should obviously be considered true given other constraints (eg, Ternary.Maybe), but we have nothing in place to capture this insight (and so do a generative structural comparison that only bottoms out when all limiters are triggered and only then return Ternary.Maybe).

I have an idea for optimizing the patterns that cause the type blowup in #15443, but the first step is to actually get a test into the compiler suite of the issue. I guess I'll do that work here~

@weswigham
Copy link
Member Author

weswigham commented May 29, 2019

I've isolated the OOM issue from fp-ts and pushed it to this PR (so it should now fail until I've got the fix done) - the minimum required code is actually rather small and quite regular in construction (and I've also stumbled upon a minor change that could be made to fp-ts to greatly speedup checking without sacrificing (much?) apparent accuracy in the current compiler without relying on a fix here - that might be worth forwarding to the library authors).

@weswigham
Copy link
Member Author

I've re-fixed #15443 in the PR (now with a test in our suite), this time by adding an optimization into assignment checking that looks for identical types among the type parameters of the source and target and exploits those to look for a broader type (usually based on a type parameter) which we may have already started to inspect (and therefore consider maybe true). With this PR in, fp-ts now takes around 23s to check, so about the same as before this PR, but now with a higher inference symbol depth limit (up to 5, from effectively 1).

@typescript-bot perf test this since this touches assignment checking now
@typescript-bot run dt and
@typescript-bot test this as well for good measure

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 29, 2019

Heya @weswigham, I've started to run the perf test suite on this PR at 37fce9f. You can monitor the build here. It should now contribute to this PR's status checks.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 29, 2019

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 37fce9f. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 29, 2019

Heya @weswigham, I've started to run the extended test suite on this PR at 37fce9f. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..31633

Metric master 31633 Delta Best Worst
Angular - node (v12.1.0, x64)
Memory used 315,000k (± 0.05%) 317,121k (± 0.01%) +2,120k (+ 0.67%) 317,019k 317,187k
Parse Time 1.38s (± 0.75%) 1.38s (± 0.42%) +0.00s (+ 0.36%) 1.37s 1.40s
Bind Time 0.72s (± 0.51%) 0.72s (± 0.69%) 0.00s ( 0.00%) 0.72s 0.74s
Check Time 4.08s (± 0.37%) 4.16s (± 0.64%) +0.07s (+ 1.81%) 4.09s 4.21s
Emit Time 5.14s (± 0.72%) 5.14s (± 0.53%) +0.00s (+ 0.04%) 5.06s 5.19s
Total Time 11.33s (± 0.38%) 11.41s (± 0.35%) +0.07s (+ 0.66%) 11.32s 11.50s
Monaco - node (v12.1.0, x64)
Memory used 343,827k (± 0.02%) 343,962k (± 0.02%) +135k (+ 0.04%) 343,815k 344,127k
Parse Time 1.17s (± 0.66%) 1.18s (± 0.49%) +0.01s (+ 1.02%) 1.17s 1.20s
Bind Time 0.67s (± 0.97%) 0.67s (± 0.71%) -0.00s (- 0.15%) 0.66s 0.68s
Check Time 4.17s (± 0.28%) 4.22s (± 0.34%) +0.05s (+ 1.30%) 4.19s 4.26s
Emit Time 2.76s (± 0.39%) 2.78s (± 0.74%) +0.02s (+ 0.83%) 2.74s 2.85s
Total Time 8.76s (± 0.24%) 8.85s (± 0.25%) +0.09s (+ 1.03%) 8.81s 8.91s
TFS - node (v12.1.0, x64)
Memory used 300,863k (± 0.01%) 300,880k (± 0.03%) +17k (+ 0.01%) 300,735k 301,054k
Parse Time 0.90s (± 0.44%) 0.90s (± 0.75%) +0.00s (+ 0.33%) 0.89s 0.92s
Bind Time 0.62s (± 0.90%) 0.62s (± 0.90%) -0.00s (- 0.00%) 0.61s 0.63s
Check Time 3.75s (± 0.49%) 3.76s (± 0.27%) +0.01s (+ 0.13%) 3.73s 3.78s
Emit Time 2.86s (± 0.76%) 2.86s (± 0.85%) -0.00s (- 0.03%) 2.81s 2.90s
Total Time 8.13s (± 0.45%) 8.14s (± 0.34%) +0.01s (+ 0.09%) 8.08s 8.20s
Angular - node (v8.9.0, x64)
Memory used 333,028k (± 0.02%) 335,203k (± 0.02%) +2,175k (+ 0.65%) 335,111k 335,338k
Parse Time 1.78s (± 0.73%) 1.77s (± 0.55%) -0.01s (- 0.56%) 1.75s 1.80s
Bind Time 0.78s (± 0.97%) 0.79s (± 0.98%) +0.01s (+ 0.89%) 0.78s 0.81s
Check Time 4.76s (± 1.19%) 4.88s (± 1.49%) +0.12s (+ 2.48%) 4.70s 5.00s
Emit Time 5.86s (± 2.21%) 5.79s (± 2.59%) -0.08s (- 1.35%) 5.51s 6.21s
Total Time 13.19s (± 0.79%) 13.22s (± 1.00%) +0.04s (+ 0.29%) 12.94s 13.52s
Monaco - node (v8.9.0, x64)
Memory used 360,956k (± 0.02%) 360,956k (± 0.02%) -0k (- 0.00%) 360,837k 361,161k
Parse Time 1.43s (± 0.59%) 1.43s (± 0.53%) +0.00s (+ 0.28%) 1.42s 1.45s
Bind Time 0.90s (± 2.30%) 0.92s (± 1.59%) +0.01s (+ 1.33%) 0.88s 0.94s
Check Time 4.99s (± 1.82%) 5.01s (± 1.67%) +0.02s (+ 0.40%) 4.93s 5.25s
Emit Time 3.18s (± 6.43%) 3.27s (± 5.00%) +0.09s (+ 2.90%) 2.83s 3.40s
Total Time 10.50s (± 1.36%) 10.63s (± 0.92%) +0.13s (+ 1.22%) 10.34s 10.75s
TFS - node (v8.9.0, x64)
Memory used 316,340k (± 0.01%) 316,375k (± 0.02%) +35k (+ 0.01%) 316,271k 316,525k
Parse Time 1.13s (± 0.42%) 1.14s (± 0.44%) +0.00s (+ 0.18%) 1.12s 1.14s
Bind Time 0.66s (± 0.79%) 0.67s (± 0.74%) +0.01s (+ 0.76%) 0.66s 0.68s
Check Time 4.33s (± 0.84%) 4.39s (± 0.70%) +0.05s (+ 1.25%) 4.33s 4.47s
Emit Time 3.10s (± 0.59%) 3.11s (± 1.23%) +0.01s (+ 0.29%) 3.00s 3.18s
Total Time 9.23s (± 0.45%) 9.30s (± 0.60%) +0.07s (+ 0.78%) 9.18s 9.40s
Angular - node (v8.9.0, x86)
Memory used 188,602k (± 0.02%) 189,680k (± 0.03%) +1,078k (+ 0.57%) 189,519k 189,794k
Parse Time 1.73s (± 0.87%) 1.73s (± 0.74%) +0.00s (+ 0.06%) 1.70s 1.76s
Bind Time 0.93s (± 1.24%) 0.94s (± 0.35%) +0.01s (+ 1.40%) 0.93s 0.95s
Check Time 4.41s (± 0.48%) 4.50s (± 0.60%) +0.09s (+ 1.95%) 4.46s 4.57s
Emit Time 5.69s (± 1.02%) 5.61s (± 1.39%) -0.08s (- 1.48%) 5.45s 5.80s
Total Time 12.76s (± 0.60%) 12.78s (± 0.76%) +0.01s (+ 0.10%) 12.56s 12.97s
Monaco - node (v8.9.0, x86)
Memory used 201,345k (± 0.02%) 201,408k (± 0.03%) +63k (+ 0.03%) 201,246k 201,493k
Parse Time 1.49s (± 0.44%) 1.48s (± 0.60%) -0.00s (- 0.27%) 1.47s 1.51s
Bind Time 0.71s (± 0.83%) 0.71s (± 0.66%) -0.00s (- 0.56%) 0.70s 0.72s
Check Time 4.76s (± 0.51%) 4.81s (± 0.67%) +0.04s (+ 0.90%) 4.73s 4.88s
Emit Time 3.10s (± 1.21%) 3.09s (± 0.54%) -0.01s (- 0.35%) 3.04s 3.13s
Total Time 10.06s (± 0.55%) 10.09s (± 0.41%) +0.03s (+ 0.26%) 10.00s 10.21s
TFS - node (v8.9.0, x86)
Memory used 177,454k (± 0.02%) 177,482k (± 0.02%) +28k (+ 0.02%) 177,428k 177,570k
Parse Time 1.19s (± 0.68%) 1.20s (± 0.89%) +0.01s (+ 0.50%) 1.17s 1.22s
Bind Time 0.63s (± 1.83%) 0.63s (± 0.64%) -0.00s (- 0.16%) 0.62s 0.64s
Check Time 4.15s (± 0.59%) 4.20s (± 0.69%) +0.05s (+ 1.18%) 4.14s 4.28s
Emit Time 2.78s (± 0.67%) 2.77s (± 0.96%) -0.01s (- 0.25%) 2.73s 2.86s
Total Time 8.75s (± 0.44%) 8.79s (± 0.44%) +0.05s (+ 0.54%) 8.69s 8.87s
Angular - node (v9.0.0, x64)
Memory used 332,873k (± 0.02%) 335,097k (± 0.02%) +2,224k (+ 0.67%) 334,935k 335,188k
Parse Time 1.62s (± 0.85%) 1.62s (± 0.38%) -0.00s (- 0.06%) 1.61s 1.63s
Bind Time 0.74s (± 1.05%) 0.74s (± 0.87%) +0.00s (+ 0.13%) 0.73s 0.76s
Check Time 4.50s (± 1.56%) 4.52s (± 1.55%) +0.03s (+ 0.62%) 4.44s 4.72s
Emit Time 5.52s (± 2.09%) 5.70s (± 2.48%) +0.17s (+ 3.13%) 5.34s 6.02s
Total Time 12.38s (± 0.48%) 12.58s (± 0.91%) +0.20s (+ 1.60%) 12.38s 12.86s
Monaco - node (v9.0.0, x64)
Memory used 360,832k (± 0.02%) 360,833k (± 0.02%) +0k (+ 0.00%) 360,674k 360,979k
Parse Time 1.28s (± 0.51%) 1.29s (± 0.59%) +0.00s (+ 0.31%) 1.27s 1.31s
Bind Time 0.85s (± 0.56%) 0.85s (± 0.47%) +0.00s (+ 0.24%) 0.84s 0.86s
Check Time 4.79s (± 0.43%) 4.86s (± 0.61%) +0.07s (+ 1.52%) 4.78s 4.91s
Emit Time 3.28s (± 0.62%) 3.29s (± 0.66%) +0.00s (+ 0.09%) 3.23s 3.35s
Total Time 10.20s (± 0.37%) 10.29s (± 0.53%) +0.08s (+ 0.82%) 10.14s 10.42s
TFS - node (v9.0.0, x64)
Memory used 316,155k (± 0.01%) 316,229k (± 0.02%) +74k (+ 0.02%) 316,126k 316,333k
Parse Time 1.01s (± 0.90%) 1.01s (± 0.69%) -0.00s (- 0.20%) 1.00s 1.03s
Bind Time 0.61s (± 0.80%) 0.61s (± 0.49%) -0.00s (- 0.33%) 0.61s 0.62s
Check Time 4.33s (± 1.87%) 4.32s (± 1.54%) -0.00s (- 0.07%) 4.25s 4.51s
Emit Time 3.07s (± 2.91%) 3.03s (± 3.00%) -0.05s (- 1.53%) 2.80s 3.16s
Total Time 9.03s (± 1.14%) 8.97s (± 0.61%) -0.05s (- 0.61%) 8.83s 9.13s
Angular - node (v9.0.0, x86)
Memory used 188,911k (± 0.03%) 189,980k (± 0.02%) +1,070k (+ 0.57%) 189,892k 190,132k
Parse Time 1.53s (± 0.86%) 1.53s (± 0.32%) -0.01s (- 0.39%) 1.51s 1.53s
Bind Time 0.87s (± 1.17%) 0.88s (± 1.38%) +0.00s (+ 0.46%) 0.85s 0.91s
Check Time 4.11s (± 0.40%) 4.17s (± 0.59%) +0.06s (+ 1.46%) 4.11s 4.22s
Emit Time 5.36s (± 0.48%) 5.32s (± 0.69%) -0.04s (- 0.73%) 5.26s 5.41s
Total Time 11.87s (± 0.27%) 11.89s (± 0.43%) +0.02s (+ 0.15%) 11.75s 11.98s
Monaco - node (v9.0.0, x86)
Memory used 201,397k (± 0.02%) 201,486k (± 0.03%) +89k (+ 0.04%) 201,388k 201,614k
Parse Time 1.31s (± 0.46%) 1.31s (± 0.77%) +0.00s (+ 0.08%) 1.29s 1.33s
Bind Time 0.64s (± 0.73%) 0.64s (± 0.97%) -0.00s (- 0.16%) 0.62s 0.65s
Check Time 4.60s (± 0.59%) 4.64s (± 0.56%) +0.04s (+ 0.80%) 4.58s 4.70s
Emit Time 3.00s (± 0.51%) 3.00s (± 0.50%) +0.01s (+ 0.23%) 2.98s 3.05s
Total Time 9.54s (± 0.27%) 9.58s (± 0.45%) +0.04s (+ 0.44%) 9.52s 9.71s
TFS - node (v9.0.0, x86)
Memory used 177,532k (± 0.02%) 177,509k (± 0.02%) -22k (- 0.01%) 177,456k 177,578k
Parse Time 1.02s (± 0.93%) 1.03s (± 0.57%) +0.01s (+ 0.98%) 1.02s 1.05s
Bind Time 0.58s (± 1.44%) 0.57s (± 0.59%) -0.00s (- 0.35%) 0.57s 0.58s
Check Time 4.03s (± 0.68%) 4.04s (± 0.75%) +0.01s (+ 0.27%) 3.99s 4.11s
Emit Time 2.70s (± 0.75%) 2.69s (± 0.71%) -0.01s (- 0.37%) 2.65s 2.73s
Total Time 8.32s (± 0.41%) 8.33s (± 0.42%) +0.01s (+ 0.08%) 8.26s 8.41s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-142-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
  • node (v9.0.0, x64)
  • node (v9.0.0, x86)
Scenarios
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Angular - node (v9.0.0, x64)
  • Angular - node (v9.0.0, x86)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • Monaco - node (v9.0.0, x64)
  • Monaco - node (v9.0.0, x86)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • TFS - node (v9.0.0, x64)
  • TFS - node (v9.0.0, x86)
Benchmark Name Iterations
Current 31633 10
Baseline master 10

…und yet, use more complete depth checking machinery
@weswigham
Copy link
Member Author

@typescript-bot run dt again - this update should fix those OOMs in DT with further improvements to how we calculate our max recursion depth in inference.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 30, 2019

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at a7a27e3. You can monitor the build here. It should now contribute to this PR's status checks.

@fatcerberus
Copy link

So, looking at fp-ts in our rwc suite, when maxSymbolRecusionDepth is 1, we compile in about 23 seconds. When maxSymbolRecusionDepth is 2 we compile in about 29 seconds. When maxSymbolRecusionDepth is >=3 we OOM.

It's just like TREE(3) 😄

@weswigham
Copy link
Member Author

weswigham commented Jan 30, 2020

Since @ahejlsberg was slightly interested in this, I've synced this PR with master; here's a new batch of test runs:

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2020

Heya @weswigham, I've started to run the parallelized community code test suite on this PR at f4d1289. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2020

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at f4d1289. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2020

Heya @weswigham, I've started to run the perf test suite on this PR at f4d1289. You can monitor the build here. It should now contribute to this PR's status checks.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2020

Heya @weswigham, I've started to run the extended test suite on this PR at f4d1289. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..31633

Metric master 31633 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 356,478k (± 0.02%) 358,213k (± 0.02%) +1,735k (+ 0.49%) 358,109k 358,351k
Parse Time 1.61s (± 0.70%) 1.62s (± 0.82%) +0.01s (+ 0.56%) 1.58s 1.64s
Bind Time 0.89s (± 0.87%) 0.88s (± 1.07%) -0.01s (- 1.01%) 0.86s 0.90s
Check Time 4.66s (± 0.38%) 4.69s (± 0.71%) +0.03s (+ 0.71%) 4.60s 4.75s
Emit Time 5.20s (± 0.95%) 5.22s (± 0.56%) +0.02s (+ 0.40%) 5.17s 5.30s
Total Time 12.35s (± 0.56%) 12.40s (± 0.49%) +0.05s (+ 0.40%) 12.23s 12.50s
Monaco - node (v10.16.3, x64)
Memory used 364,587k (± 0.02%) 364,611k (± 0.01%) +25k (+ 0.01%) 364,484k 364,692k
Parse Time 1.25s (± 0.64%) 1.25s (± 0.42%) +0.00s (+ 0.08%) 1.24s 1.26s
Bind Time 0.77s (± 1.06%) 0.77s (± 0.62%) 0.00s ( 0.00%) 0.76s 0.78s
Check Time 4.70s (± 0.83%) 4.68s (± 0.46%) -0.01s (- 0.26%) 4.64s 4.73s
Emit Time 2.92s (± 0.99%) 2.88s (± 0.71%) -0.04s (- 1.44%) 2.82s 2.93s
Total Time 9.64s (± 0.56%) 9.58s (± 0.33%) -0.05s (- 0.56%) 9.51s 9.65s
TFS - node (v10.16.3, x64)
Memory used 324,106k (± 0.02%) 324,089k (± 0.02%) -17k (- 0.01%) 323,950k 324,203k
Parse Time 0.94s (± 0.63%) 0.94s (± 0.72%) 0.00s ( 0.00%) 0.93s 0.96s
Bind Time 0.74s (± 1.62%) 0.75s (± 1.21%) +0.01s (+ 1.49%) 0.74s 0.78s
Check Time 4.22s (± 0.54%) 4.21s (± 0.66%) -0.00s (- 0.07%) 4.17s 4.30s
Emit Time 3.00s (± 0.83%) 3.00s (± 1.35%) -0.01s (- 0.20%) 2.88s 3.05s
Total Time 8.90s (± 0.42%) 8.90s (± 0.73%) +0.00s (+ 0.03%) 8.74s 9.03s
Angular - node (v12.1.0, x64)
Memory used 332,150k (± 0.01%) 333,793k (± 0.02%) +1,643k (+ 0.49%) 333,657k 333,931k
Parse Time 1.56s (± 0.75%) 1.56s (± 0.65%) +0.01s (+ 0.32%) 1.54s 1.58s
Bind Time 0.86s (± 0.72%) 0.87s (± 0.76%) +0.01s (+ 1.05%) 0.86s 0.89s
Check Time 4.58s (± 0.38%) 4.58s (± 0.47%) +0.00s (+ 0.04%) 4.54s 4.62s
Emit Time 5.39s (± 0.61%) 5.38s (± 0.85%) -0.01s (- 0.15%) 5.31s 5.52s
Total Time 12.39s (± 0.39%) 12.39s (± 0.42%) +0.01s (+ 0.06%) 12.28s 12.50s
Monaco - node (v12.1.0, x64)
Memory used 344,448k (± 0.01%) 344,460k (± 0.02%) +12k (+ 0.00%) 344,345k 344,608k
Parse Time 1.21s (± 0.70%) 1.21s (± 0.75%) 0.00s ( 0.00%) 1.19s 1.23s
Bind Time 0.74s (± 0.83%) 0.75s (± 1.02%) +0.00s (+ 0.67%) 0.74s 0.77s
Check Time 4.53s (± 0.53%) 4.53s (± 0.41%) +0.00s (+ 0.09%) 4.47s 4.57s
Emit Time 2.95s (± 0.86%) 2.95s (± 0.82%) -0.00s (- 0.07%) 2.91s 3.03s
Total Time 9.43s (± 0.47%) 9.44s (± 0.27%) +0.01s (+ 0.06%) 9.40s 9.51s
TFS - node (v12.1.0, x64)
Memory used 306,368k (± 0.02%) 306,377k (± 0.03%) +9k (+ 0.00%) 306,223k 306,569k
Parse Time 0.93s (± 0.64%) 0.94s (± 0.81%) +0.00s (+ 0.11%) 0.92s 0.96s
Bind Time 0.70s (± 0.68%) 0.70s (± 0.74%) -0.00s (- 0.28%) 0.69s 0.71s
Check Time 4.19s (± 0.46%) 4.16s (± 0.41%) -0.02s (- 0.57%) 4.12s 4.20s
Emit Time 3.06s (± 0.69%) 3.09s (± 0.81%) +0.03s (+ 0.85%) 3.05s 3.17s
Total Time 8.89s (± 0.35%) 8.89s (± 0.33%) +0.00s (+ 0.06%) 8.82s 8.96s
Angular - node (v8.9.0, x64)
Memory used 351,506k (± 0.02%) 353,135k (± 0.01%) +1,629k (+ 0.46%) 353,036k 353,208k
Parse Time 2.09s (± 0.37%) 2.11s (± 0.28%) +0.02s (+ 0.86%) 2.10s 2.12s
Bind Time 0.92s (± 1.53%) 0.93s (± 0.64%) +0.02s (+ 1.85%) 0.92s 0.95s
Check Time 5.43s (± 0.58%) 5.48s (± 0.77%) +0.05s (+ 1.00%) 5.40s 5.55s
Emit Time 6.12s (± 0.96%) 6.22s (± 0.97%) +0.10s (+ 1.72%) 6.03s 6.34s
Total Time 14.55s (± 0.43%) 14.75s (± 0.59%) +0.20s (+ 1.37%) 14.50s 14.90s
Monaco - node (v8.9.0, x64)
Memory used 362,850k (± 0.01%) 362,904k (± 0.01%) +54k (+ 0.01%) 362,777k 362,998k
Parse Time 1.56s (± 0.26%) 1.55s (± 0.45%) -0.01s (- 0.64%) 1.54s 1.57s
Bind Time 0.95s (± 0.38%) 0.95s (± 0.74%) +0.01s (+ 0.53%) 0.94s 0.97s
Check Time 5.37s (± 1.63%) 5.35s (± 1.72%) -0.02s (- 0.39%) 5.22s 5.62s
Emit Time 3.26s (± 4.27%) 3.33s (± 3.81%) +0.07s (+ 2.06%) 2.98s 3.44s
Total Time 11.13s (± 0.55%) 11.18s (± 0.56%) +0.04s (+ 0.38%) 11.04s 11.29s
TFS - node (v8.9.0, x64)
Memory used 323,379k (± 0.02%) 323,390k (± 0.01%) +11k (+ 0.00%) 323,283k 323,450k
Parse Time 1.26s (± 0.38%) 1.26s (± 0.65%) +0.00s (+ 0.24%) 1.25s 1.29s
Bind Time 0.76s (± 0.62%) 0.75s (± 0.53%) -0.01s (- 1.18%) 0.74s 0.76s
Check Time 4.85s (± 0.52%) 4.85s (± 0.54%) -0.00s (- 0.02%) 4.78s 4.91s
Emit Time 3.20s (± 0.64%) 3.20s (± 0.76%) -0.00s (- 0.09%) 3.17s 3.29s
Total Time 10.07s (± 0.38%) 10.06s (± 0.39%) -0.01s (- 0.12%) 9.96s 10.15s
Angular - node (v8.9.0, x86)
Memory used 199,848k (± 0.03%) 200,768k (± 0.03%) +920k (+ 0.46%) 200,648k 200,883k
Parse Time 2.03s (± 0.26%) 2.05s (± 0.65%) +0.02s (+ 0.89%) 2.02s 2.09s
Bind Time 1.03s (± 0.74%) 1.05s (± 0.69%) +0.02s (+ 1.64%) 1.03s 1.06s
Check Time 4.98s (± 0.46%) 4.95s (± 0.95%) -0.03s (- 0.60%) 4.87s 5.10s
Emit Time 5.99s (± 0.57%) 6.11s (± 2.65%) +0.12s (+ 1.94%) 5.85s 6.53s
Total Time 14.04s (± 0.29%) 14.16s (± 1.32%) +0.12s (+ 0.87%) 13.86s 14.59s
Monaco - node (v8.9.0, x86)
Memory used 203,737k (± 0.02%) 203,754k (± 0.01%) +16k (+ 0.01%) 203,700k 203,828k
Parse Time 1.59s (± 0.55%) 1.60s (± 0.47%) +0.01s (+ 0.38%) 1.58s 1.61s
Bind Time 0.77s (± 1.78%) 0.78s (± 1.36%) +0.01s (+ 0.91%) 0.76s 0.81s
Check Time 5.15s (± 1.12%) 5.17s (± 1.31%) +0.03s (+ 0.51%) 5.05s 5.34s
Emit Time 3.17s (± 1.30%) 3.18s (± 1.51%) +0.01s (+ 0.28%) 3.03s 3.24s
Total Time 10.68s (± 0.43%) 10.72s (± 0.46%) +0.05s (+ 0.43%) 10.61s 10.83s
TFS - node (v8.9.0, x86)
Memory used 182,561k (± 0.02%) 182,542k (± 0.03%) -19k (- 0.01%) 182,416k 182,638k
Parse Time 1.30s (± 0.84%) 1.30s (± 0.58%) -0.00s (- 0.08%) 1.28s 1.31s
Bind Time 0.71s (± 0.73%) 0.71s (± 0.94%) +0.00s (+ 0.56%) 0.70s 0.73s
Check Time 4.56s (± 0.49%) 4.59s (± 0.71%) +0.02s (+ 0.50%) 4.54s 4.70s
Emit Time 2.95s (± 1.11%) 2.94s (± 0.72%) -0.02s (- 0.58%) 2.89s 2.98s
Total Time 9.53s (± 0.53%) 9.53s (± 0.34%) +0.01s (+ 0.08%) 9.48s 9.60s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-166-generic
Architecturex64
Available Memory16 GB
Available Memory4 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)
Benchmark Name Iterations
Current 31633 10
Baseline master 10

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

@weswigham
Copy link
Member Author

Perf looks good, and the changes seem good in the places with changes (sometimes it's less errors from better matching recursive structures, but in some places we issue a new error from improved inference around flatten or flatten-list object stuctures where we now infer both the T and the T[], which confounds some things), but immutable crashes in the user suite with an OOM, so I'll have to look into why the assignability opimizations that helped fp-ts weren't sufficient for immutable.

@weswigham
Copy link
Member Author

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

immutable should no longer crash; I've fixed the bug I introduced in the merge and also added some special casing for any in the assumptive broadening comparisons.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 31, 2020

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at c79e70d. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 31, 2020

Heya @weswigham, I've started to run the extended test suite on this PR at c79e70d. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 31, 2020

Heya @weswigham, I've started to run the perf test suite on this PR at c79e70d. You can monitor the build here. It should now contribute to this PR's status checks.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 31, 2020

Heya @weswigham, I've started to run the parallelized community code test suite on this PR at c79e70d. You can monitor the build here. It should now contribute to this PR's status checks.

@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

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

Here they are:

Comparison Report - master..31633

Metric master 31633 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 356,487k (± 0.01%) 358,026k (± 0.03%) +1,539k (+ 0.43%) 357,800k 358,219k
Parse Time 1.61s (± 0.54%) 1.61s (± 0.41%) +0.01s (+ 0.31%) 1.60s 1.63s
Bind Time 0.89s (± 0.93%) 0.88s (± 0.73%) -0.01s (- 1.34%) 0.87s 0.90s
Check Time 4.68s (± 0.52%) 4.69s (± 0.31%) +0.01s (+ 0.32%) 4.67s 4.73s
Emit Time 5.23s (± 0.88%) 5.20s (± 0.71%) -0.03s (- 0.61%) 5.13s 5.30s
Total Time 12.42s (± 0.53%) 12.39s (± 0.44%) -0.03s (- 0.24%) 12.30s 12.55s
Monaco - node (v10.16.3, x64)
Memory used 364,648k (± 0.01%) 364,626k (± 0.02%) -22k (- 0.01%) 364,416k 364,788k
Parse Time 1.26s (± 0.64%) 1.25s (± 0.40%) -0.01s (- 0.95%) 1.23s 1.25s
Bind Time 0.78s (± 0.48%) 0.77s (± 0.38%) -0.00s (- 0.39%) 0.77s 0.78s
Check Time 4.68s (± 0.33%) 4.69s (± 0.45%) +0.01s (+ 0.19%) 4.66s 4.75s
Emit Time 2.91s (± 0.83%) 2.92s (± 1.00%) +0.01s (+ 0.38%) 2.87s 2.99s
Total Time 9.63s (± 0.44%) 9.63s (± 0.38%) +0.00s (+ 0.03%) 9.54s 9.70s
TFS - node (v10.16.3, x64)
Memory used 324,119k (± 0.02%) 324,077k (± 0.02%) -42k (- 0.01%) 323,893k 324,261k
Parse Time 0.94s (± 0.72%) 0.94s (± 0.39%) 0.00s ( 0.00%) 0.94s 0.95s
Bind Time 0.74s (± 1.00%) 0.75s (± 1.32%) +0.01s (+ 0.67%) 0.72s 0.76s
Check Time 4.25s (± 0.34%) 4.24s (± 0.50%) -0.02s (- 0.38%) 4.20s 4.28s
Emit Time 3.04s (± 0.70%) 3.03s (± 0.84%) -0.00s (- 0.13%) 2.98s 3.09s
Total Time 8.98s (± 0.29%) 8.96s (± 0.28%) -0.01s (- 0.16%) 8.89s 9.02s
Angular - node (v12.1.0, x64)
Memory used 332,156k (± 0.02%) 333,677k (± 0.05%) +1,522k (+ 0.46%) 333,046k 333,933k
Parse Time 1.56s (± 0.53%) 1.56s (± 0.44%) +0.01s (+ 0.51%) 1.55s 1.58s
Bind Time 0.86s (± 0.46%) 0.87s (± 0.55%) +0.01s (+ 0.70%) 0.86s 0.88s
Check Time 4.56s (± 0.46%) 4.60s (± 0.49%) +0.04s (+ 0.77%) 4.56s 4.67s
Emit Time 5.37s (± 0.64%) 5.41s (± 0.56%) +0.04s (+ 0.69%) 5.33s 5.48s
Total Time 12.35s (± 0.39%) 12.44s (± 0.24%) +0.09s (+ 0.72%) 12.37s 12.51s
Monaco - node (v12.1.0, x64)
Memory used 344,446k (± 0.01%) 344,528k (± 0.02%) +83k (+ 0.02%) 344,418k 344,686k
Parse Time 1.21s (± 0.51%) 1.21s (± 0.77%) -0.00s (- 0.25%) 1.19s 1.23s
Bind Time 0.75s (± 0.99%) 0.74s (± 0.80%) -0.01s (- 1.06%) 0.73s 0.76s
Check Time 4.56s (± 0.40%) 4.55s (± 0.72%) -0.01s (- 0.22%) 4.50s 4.63s
Emit Time 2.96s (± 0.42%) 2.96s (± 0.37%) +0.00s (+ 0.17%) 2.93s 2.98s
Total Time 9.48s (± 0.28%) 9.46s (± 0.50%) -0.02s (- 0.19%) 9.36s 9.58s
TFS - node (v12.1.0, x64)
Memory used 306,392k (± 0.02%) 306,405k (± 0.03%) +13k (+ 0.00%) 306,235k 306,581k
Parse Time 0.95s (± 0.63%) 0.93s (± 0.69%) -0.01s (- 1.48%) 0.92s 0.95s
Bind Time 0.70s (± 0.83%) 0.70s (± 0.70%) +0.00s (+ 0.14%) 0.70s 0.72s
Check Time 4.20s (± 0.34%) 4.16s (± 0.49%) -0.03s (- 0.79%) 4.11s 4.21s
Emit Time 3.09s (± 0.92%) 3.08s (± 0.52%) -0.01s (- 0.42%) 3.04s 3.13s
Total Time 8.94s (± 0.36%) 8.88s (± 0.30%) -0.06s (- 0.69%) 8.81s 8.94s
Angular - node (v8.9.0, x64)
Memory used 351,525k (± 0.01%) 353,113k (± 0.01%) +1,588k (+ 0.45%) 352,998k 353,207k
Parse Time 2.10s (± 0.26%) 2.12s (± 0.59%) +0.02s (+ 0.86%) 2.09s 2.14s
Bind Time 0.93s (± 0.64%) 0.94s (± 0.51%) +0.01s (+ 1.19%) 0.92s 0.94s
Check Time 5.49s (± 0.58%) 5.50s (± 0.65%) +0.02s (+ 0.33%) 5.39s 5.56s
Emit Time 6.25s (± 1.01%) 6.29s (± 0.74%) +0.04s (+ 0.58%) 6.18s 6.40s
Total Time 14.76s (± 0.53%) 14.84s (± 0.49%) +0.08s (+ 0.56%) 14.66s 15.01s
Monaco - node (v8.9.0, x64)
Memory used 362,892k (± 0.02%) 362,947k (± 0.01%) +55k (+ 0.02%) 362,874k 363,046k
Parse Time 1.55s (± 0.42%) 1.56s (± 0.32%) +0.00s (+ 0.19%) 1.55s 1.57s
Bind Time 0.96s (± 0.54%) 0.95s (± 0.47%) -0.01s (- 1.35%) 0.94s 0.96s
Check Time 5.42s (± 1.76%) 5.42s (± 1.71%) -0.00s (- 0.04%) 5.27s 5.65s
Emit Time 3.29s (± 4.08%) 3.28s (± 4.61%) -0.01s (- 0.33%) 2.97s 3.47s
Total Time 11.22s (± 0.59%) 11.20s (± 0.64%) -0.02s (- 0.19%) 11.01s 11.32s
TFS - node (v8.9.0, x64)
Memory used 323,403k (± 0.02%) 323,449k (± 0.01%) +46k (+ 0.01%) 323,350k 323,542k
Parse Time 1.26s (± 0.54%) 1.26s (± 0.35%) -0.00s (- 0.16%) 1.25s 1.27s
Bind Time 0.76s (± 0.59%) 0.75s (± 0.48%) -0.00s (- 0.53%) 0.75s 0.76s
Check Time 4.86s (± 0.56%) 4.82s (± 0.71%) -0.03s (- 0.66%) 4.75s 4.90s
Emit Time 3.20s (± 0.50%) 3.20s (± 0.59%) -0.01s (- 0.22%) 3.16s 3.24s
Total Time 10.07s (± 0.30%) 10.03s (± 0.45%) -0.04s (- 0.41%) 9.96s 10.12s
Angular - node (v8.9.0, x86)
Memory used 199,887k (± 0.02%) 200,741k (± 0.02%) +854k (+ 0.43%) 200,638k 200,814k
Parse Time 2.03s (± 0.44%) 2.03s (± 0.55%) 0.00s ( 0.00%) 2.01s 2.06s
Bind Time 1.03s (± 0.80%) 1.05s (± 0.74%) +0.01s (+ 1.45%) 1.03s 1.07s
Check Time 4.95s (± 0.43%) 4.96s (± 0.54%) +0.01s (+ 0.16%) 4.92s 5.04s
Emit Time 6.06s (± 1.40%) 6.15s (± 1.57%) +0.08s (+ 1.40%) 6.00s 6.36s
Total Time 14.08s (± 0.65%) 14.19s (± 0.66%) +0.11s (+ 0.76%) 14.03s 14.39s
Monaco - node (v8.9.0, x86)
Memory used 203,770k (± 0.02%) 203,781k (± 0.02%) +12k (+ 0.01%) 203,688k 203,885k
Parse Time 1.61s (± 0.90%) 1.60s (± 0.69%) -0.01s (- 0.50%) 1.58s 1.63s
Bind Time 0.78s (± 1.15%) 0.76s (± 0.81%) -0.01s (- 1.81%) 0.75s 0.78s
Check Time 5.15s (± 0.80%) 5.17s (± 1.73%) +0.02s (+ 0.41%) 5.07s 5.42s
Emit Time 3.20s (± 1.67%) 3.11s (± 3.81%) -0.08s (- 2.57%) 2.70s 3.25s
Total Time 10.73s (± 0.37%) 10.65s (± 0.55%) -0.08s (- 0.73%) 10.47s 10.73s
TFS - node (v8.9.0, x86)
Memory used 182,571k (± 0.02%) 182,617k (± 0.02%) +45k (+ 0.02%) 182,531k 182,694k
Parse Time 1.30s (± 1.14%) 1.30s (± 0.67%) +0.00s (+ 0.15%) 1.28s 1.32s
Bind Time 0.71s (± 1.13%) 0.71s (± 0.84%) -0.00s (- 0.28%) 0.70s 0.72s
Check Time 4.60s (± 1.00%) 4.59s (± 0.51%) -0.01s (- 0.28%) 4.55s 4.65s
Emit Time 2.96s (± 0.49%) 2.97s (± 1.63%) +0.01s (+ 0.30%) 2.87s 3.14s
Total Time 9.57s (± 0.79%) 9.57s (± 0.64%) -0.00s (- 0.05%) 9.46s 9.78s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-166-generic
Architecturex64
Available Memory16 GB
Available Memory4 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)
Benchmark Name Iterations
Current 31633 10
Baseline master 10

@sandersn sandersn added the For Milestone Bug PRs that fix a bug with a specific milestone label Feb 1, 2020
@weswigham weswigham added this to the TypeScript 3.9.0 milestone Feb 10, 2020
@weswigham
Copy link
Member Author

@ahejlsberg said to punt this from 3.8 because of it's complexity, but it's still going to need a timely review to get into 3.9; so that'd be much appreciated ❤️

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

The high-level description sounds plausible, but the implementation reminds me of ad-hoc extensions to assignability that I've tried before. I'll defer to @ahejlsberg for whether we want to add it, since it seems like it mostly helps just fp-ts.

// This is difficult to detect generally, so we scan for prior comparisons of the same instantiated type, and match up matching
// type arguments into sets to create a canonicalization based on those matches
if (relation !== identityRelation && ((source.aliasSymbol && !source.aliasTypeArgumentsContainsMarker && source.aliasTypeArguments) || (getObjectFlags(source) & ObjectFlags.Reference && !!getTypeArguments(<TypeReference>source).length && !(getObjectFlags(source) & ObjectFlags.MarkerType))) &&
((target.aliasSymbol && !target.aliasTypeArgumentsContainsMarker && target.aliasTypeArguments) || (getObjectFlags(target) & ObjectFlags.Reference && !!getTypeArguments(<TypeReference>target).length && !(getObjectFlags(target) & ObjectFlags.MarkerType)))) {
Copy link
Member

Choose a reason for hiding this comment

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

might be worth it to extract a function for this predicate, if only to make the name obvious.

(the line length is also too long)

declare function load(name: string): Promise<string>;
declare function convert(s: string): IPromise<number>;

var $$x = load("something").then(s => convert(s));
Copy link
Member

Choose a reason for hiding this comment

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

why is this error gone now? does overload resolution follow the new code path in assignability now?

Copy link
Member Author

Choose a reason for hiding this comment

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

We now successfully identify that Promise<T> and IPromise<T> are identical, and so no longer fail inference when relating their then signatures~

@sandersn
Copy link
Member

Unfortunately, we never finished reviewing this PR. It is pretty old now, so I'm going to close it to reduce the number of open PRs.

@sandersn sandersn closed this May 24, 2022
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
Development

Successfully merging this pull request may close these issues.

Type alias substitution does not work
7 participants