Skip to content

Infer type predicates for functions with multiple returns - #58154

Closed
Dan Vanderkam (danvk) wants to merge 5 commits into
microsoft:mainfrom
danvk:multi-return-predicate
Closed

Infer type predicates for functions with multiple returns#58154
Dan Vanderkam (danvk) wants to merge 5 commits into
microsoft:mainfrom
danvk:multi-return-predicate

Conversation

@danvk

@danvkDan Vanderkam (danvk) commented Apr 11, 2024

Copy link
Copy Markdown
Contributor

Follow-on to #57465

The original PR restricted itself to functions with a single return. This PR lifts that restriction.

This allows us to infer predicates for constructs like this:

// infers x is string | DatefunctionifElseIfPredicate(x: string|number|Date){if(typeofx==='string'){returntrue;}elseif(xinstanceofDate){returntrue;}returnfalse;}

or

// infers str is "a" | "b" | "c"functionswitchPredicate(str: string){switch(str){case'a':
case'b':
case'c':
returntruedefault:
returnfalse}}

How this works

Type predicate inference works by rewriting return statements from:

functionfoo(p: InitType){returnexpr_involving_p;}

to:

functionfoo(p: InitType){if(expr_involving_p){p// TrueType}else{p// FalseType}}

If TrueType != InitType then we have a candidate for a type predicate. To generalize this to multiple returns, we determine the TrueType at each return statement and union them. These are all the parameter types for which the function can return true.

To verify the "if and only if" semantics of type predicates, we feed the type predicate type back into the function and look at all the false cases. For a valid type predicate, these should all be never.

I've also special-cased return true and return false. These weren't especially relevant when getTypePredicateFromBody only allowed one return, but they're very relevant now.

Why this might be a good idea

Like #57465, this should only produce valid type predicates, which should result in more precise types.

This makes inferred type predicates less sensitive to seemingly irrelevant refactors, such as:

// may have an inferred type predicatefunctionf1(arg){returncond1(arg)&&cond2(arg);}// cannot have an inferred type predicate in TS 5.5functionf1(arg){if(!cond1(arg))returnfalse;returncond2(arg);}

These kinds of refactors don't affect inferred return types, so it may be surprising that they affect inferred type predicates.

While this does result in predicate inference running on more functions, the perf impact seems to be minimal.

Why this might not be a good idea

Multi-return type predicates are not as common as single-return type predicates:

So the impact will be relatively small compared to the original change.

This does make the type predicate inference code a bit harder to follow since we're always working with Type[] instead of Type.

Moreover, I got a new circularity error in emitter.ts. This would also have been a new circularity error with #57465, but the type predicate inference code didn't run because one of the functions had two returns. This change increases the odds that this happens on existing code. This error no longer happens.

@typescript-botTypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Apr 11, 2024
@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 11, 2024

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
test top400✅ Started✅ Results
user test this✅ Started✅ Results
run dt✅ Started✅ Results
perf test this faster✅ Started👀 Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user tests comparing main and refs/pull/58154/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Angular - node (v18.15.0, x64)
Memory used295,945k (± 0.01%)295,933k (± 0.01%)~295,885k295,972kp=0.630 n=6
Parse Time2.65s (± 0.51%)2.66s (± 0.51%)~2.63s2.67sp=0.547 n=6
Bind Time0.82s (± 1.62%)0.82s (± 1.33%)~0.81s0.83sp=0.859 n=6
Check Time8.23s (± 0.27%)8.25s (± 0.25%)~8.21s8.27sp=0.517 n=6
Emit Time7.05s (± 0.15%)7.05s (± 0.22%)~7.03s7.07sp=0.218 n=6
Total Time18.77s (± 0.08%)18.77s (± 0.20%)~18.73s18.83sp=0.511 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used191,643k (± 0.02%)194,175k (± 0.92%)+2,532k (+ 1.32%)191,823k195,435kp=0.005 n=6
Parse Time1.35s (± 0.62%)1.37s (± 1.00%)~1.35s1.39sp=0.109 n=6
Bind Time0.72s (± 0.57%)0.72s (± 0.00%)~0.72s0.72sp=0.405 n=6
Check Time9.43s (± 0.25%)9.45s (± 0.71%)~9.38s9.54sp=0.748 n=6
Emit Time2.61s (± 1.16%)2.62s (± 1.20%)~2.56s2.64sp=0.685 n=6
Total Time14.11s (± 0.29%)14.15s (± 0.54%)~14.09s14.26sp=0.520 n=6
Monaco - node (v18.15.0, x64)
Memory used347,723k (± 0.01%)347,734k (± 0.00%)~347,723k347,749kp=0.630 n=6
Parse Time2.48s (± 0.59%)2.48s (± 0.54%)~2.46s2.50sp=1.000 n=6
Bind Time0.89s (± 0.58%)0.89s (± 0.91%)~0.89s0.91sp=0.114 n=6
Check Time6.97s (± 0.51%)6.96s (± 0.17%)~6.95s6.98sp=0.871 n=6
Emit Time4.07s (± 0.36%)4.07s (± 0.25%)~4.06s4.08sp=0.530 n=6
Total Time14.41s (± 0.16%)14.42s (± 0.19%)~14.38s14.46sp=0.808 n=6
TFS - node (v18.15.0, x64)
Memory used302,608k (± 0.01%)302,608k (± 0.01%)~302,585k302,652kp=0.810 n=6
Parse Time2.39s (± 0.97%)2.41s (± 0.59%)~2.39s2.43sp=0.075 n=6
Bind Time1.16s (± 0.35%)1.16s (± 0.35%)~1.16s1.17sp=0.218 n=6
Check Time7.45s (± 0.31%)7.46s (± 0.49%)~7.40s7.50sp=0.331 n=6
Emit Time4.27s (± 0.58%)4.27s (± 0.75%)~4.23s4.32sp=0.684 n=6
Total Time15.27s (± 0.26%)15.31s (± 0.36%)~15.24s15.36sp=0.260 n=6
material-ui - node (v18.15.0, x64)
Memory used510,584k (± 0.01%)510,609k (± 0.01%)~510,579k510,651kp=0.128 n=6
Parse Time2.66s (± 0.51%)2.67s (± 0.76%)~2.64s2.70sp=0.164 n=6
Bind Time0.98s (± 1.58%)0.99s (± 0.83%)~0.98s1.00sp=0.510 n=6
Check Time17.20s (± 0.28%)17.21s (± 0.31%)~17.11s17.25sp=0.288 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time20.84s (± 0.21%)20.88s (± 0.29%)~20.77s20.93sp=0.226 n=6
mui-docs - node (v18.15.0, x64)
Memory used1,742,692k (± 0.00%)1,742,670k (± 0.00%)~1,742,605k1,742,747kp=0.261 n=6
Parse Time7.85s (± 0.51%)7.85s (± 0.78%)~7.79s7.96sp=0.808 n=6
Bind Time2.74s (± 0.89%)2.75s (± 0.87%)~2.71s2.78sp=0.566 n=6
Check Time66.40s (± 0.38%)66.40s (± 0.47%)~65.87s66.75sp=0.872 n=6
Emit Time0.16s (± 0.00%)0.16s (± 3.29%)~0.15s0.16sp=0.174 n=6
Total Time77.15s (± 0.34%)77.16s (± 0.38%)~76.62s77.49sp=0.936 n=6
self-build-src - node (v18.15.0, x64)
Memory used2,303,056k (± 0.04%)2,302,781k (± 0.02%)~2,302,126k2,303,189kp=1.000 n=6
Parse Time7.38s (± 0.63%)7.37s (± 1.18%)~7.29s7.53sp=0.575 n=6
Bind Time2.76s (± 0.58%)2.73s (± 0.88%)~2.71s2.77sp=0.065 n=6
Check Time48.73s (± 0.41%)48.91s (± 0.72%)~48.44s49.48sp=0.471 n=6
Emit Time3.88s (± 2.57%)3.86s (± 3.57%)~3.72s4.12sp=0.689 n=6
Total Time62.75s (± 0.38%)62.90s (± 0.66%)~62.41s63.62sp=0.520 n=6
self-build-src-public-api - node (v18.15.0, x64)
Memory used2,377,109k (± 0.03%)2,377,257k (± 0.03%)~2,376,567k2,378,563kp=0.936 n=6
Parse Time7.65s (± 1.03%)7.65s (± 0.81%)~7.54s7.72sp=0.810 n=6
Bind Time2.50s (± 0.89%)2.48s (± 0.49%)~2.47s2.50sp=0.171 n=6
Check Time49.30s (± 0.14%)49.23s (± 0.37%)~49.01s49.46sp=0.810 n=6
Emit Time3.91s (± 3.34%)3.94s (± 1.93%)~3.86s4.07sp=0.873 n=6
Total Time63.35s (± 0.22%)63.33s (± 0.34%)~63.12s63.68sp=0.936 n=6
self-compiler - node (v18.15.0, x64)
Memory used418,399k (± 0.01%)418,502k (± 0.01%)+102k (+ 0.02%)418,447k418,549kp=0.005 n=6
Parse Time4.18s (± 0.41%)4.18s (± 0.33%)~4.16s4.20sp=0.742 n=6
Bind Time1.59s (± 2.71%)1.58s (± 0.57%)~1.57s1.59sp=1.000 n=6
Check Time22.05s (± 0.25%)22.08s (± 0.35%)~21.97s22.20sp=0.470 n=6
Emit Time1.69s (± 1.10%)1.70s (± 1.25%)~1.66s1.72sp=0.278 n=6
Total Time29.51s (± 0.29%)29.54s (± 0.30%)~29.44s29.71sp=0.470 n=6
vscode - node (v18.15.0, x64)
Memory used2,907,545k (± 0.00%)2,907,535k (± 0.00%)~2,907,468k2,907,596kp=0.689 n=6
Parse Time15.93s (± 0.26%)15.99s (± 0.47%)~15.92s16.13sp=0.077 n=6
Bind Time4.91s (± 0.47%)4.91s (± 0.38%)~4.88s4.93sp=0.628 n=6
Check Time86.42s (± 0.27%)85.99s (± 0.26%)-0.43s (- 0.50%)85.71s86.39sp=0.020 n=6
Emit Time23.62s (± 0.49%)23.55s (± 0.62%)~23.31s23.72sp=0.748 n=6
Total Time130.88s (± 0.20%)130.44s (± 0.25%)-0.44s (- 0.34%)129.89s130.84sp=0.031 n=6
webpack - node (v18.15.0, x64)
Memory used408,686k (± 0.01%)408,690k (± 0.01%)~408,646k408,774kp=0.748 n=6
Parse Time3.87s (± 0.72%)3.86s (± 0.48%)~3.85s3.90sp=0.870 n=6
Bind Time1.67s (± 1.05%)1.66s (± 0.93%)~1.63s1.67sp=0.618 n=6
Check Time16.73s (± 0.30%)16.71s (± 0.29%)~16.64s16.78sp=0.298 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time22.27s (± 0.37%)22.23s (± 0.27%)~22.17s22.31sp=0.521 n=6
xstate - node (v18.15.0, x64)
Memory used670,847k (± 0.02%)670,841k (± 0.01%)~670,735k670,942kp=1.000 n=6
Parse Time4.98s (± 0.35%)4.98s (± 0.68%)~4.95s5.03sp=0.520 n=6
Bind Time2.32s (± 0.76%)2.32s (± 0.85%)~2.30s2.35sp=0.870 n=6
Check Time4.20s (± 0.79%)4.24s (± 1.48%)~4.15s4.31sp=0.295 n=6
Emit Time0.03s (± 0.00%)0.03s (± 0.00%)~0.03s0.03sp=1.000 n=6
Total Time11.54s (± 0.48%)11.58s (± 0.79%)~11.45s11.71sp=0.419 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos comparing main and refs/pull/58154/merge:

Everything looks good!

@danvk

Copy link
Copy Markdown
ContributorAuthor

👀 So minimal perf impact and no breaks beyond the self-check circularity issue. Maybe this is a good idea? 🤔

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test top800

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 12, 2024

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
test top800✅ Started✅ Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 800 repos comparing main and refs/pull/58154/merge:

Everything looks good!

@danvk

Copy link
Copy Markdown
ContributorAuthor

I put up #58173, which reports an error whenever it infers a type predicate for a function with multiple return statements. That should clarify how common this pattern is in the wild.

@danvk

Copy link
Copy Markdown
ContributorAuthor

Results of the experiment:

  • three new type predicates in TypeScript itself, one of which had an impact
  • one new type predicate in pyright
  • three new type predicates in the top400 suite

So not many functions match this pattern in the wild, but a few do and there's also not a big perf impact. Up to TS team whether this is a helpful generalization. See Jake Bailey (@jakebailey)'s comment #58173 (comment)

@anka-213

Copy link
Copy Markdown

I would love to have this, since it allows splitting up type predicates instead of having to write them as a single long expression. I'm surprised that things like

functionisArrayOfStrings(x: unknown): x is string[]{if(!xinstanceofArray)returnfalse;returnx.every((y)=>typeofy==='string');}

didn't occur more in your experiment, since I've seen it pretty often for more complicated type predicates.

@danvk

Dan Vanderkam (danvk) commented Apr 29, 2024

Copy link
Copy Markdown
ContributorAuthor

Andreas Källberg (@anka-213) if there are examples in the wild that you can point to, that would be helpful. This makes me realize that my experiment (#58173) would not tell us about existing type predicates with 2+ returns, since the predicate inference code doesn't run if there's an explicit return type annotation. In other words, it would not have detected your isArrayOfStrings function. Finding functions like this would be another interesting data point.

FWIW you can break up the long expression by factoring out a variable, you just can't break up the control flow:

// function isArrayOfStrings(x: unknown): x is string[]functionisArrayOfStrings(x: unknown){constisArray=Array.isArray(x);returnisArray&&(x.every((y)=>typeofy==='string'));}

playground

@danvkDan Vanderkam (danvk) changed the title Experiment: Infer type predicates for functions with multiple returnsInfer type predicates for functions with multiple returnsMay 15, 2024
@danvk
Dan Vanderkam (danvk) marked this pull request as ready for review July 11, 2024 19:23
@typescript-bot

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@danvk

Copy link
Copy Markdown
ContributorAuthor

I've merged upstream changes and brought the implementation more in line with main to reduce the diff. I've also updated the PR description in light of the experiments and performance numbers from April. Jake Bailey (@jakebailey) it would be interesting to get new performance numbers to see if the "minimal impact" holds up.

I can open an issue like typescript-bot suggests if that would be a more appropriate way to discuss the merits of this extension.

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
test top400✅ Started✅ Results
user test this✅ Started✅ Results
run dt✅ Started✅ Results
perf test this faster✅ Started👀 Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing main and refs/pull/58154/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15362,209+56 (+ 0.09%)~~p=0.001 n=6
Types50,24250,258+16 (+ 0.03%)~~p=0.001 n=6
Memory used193,995k (± 0.97%)192,611k (± 0.82%)~191,875k195,832kp=0.066 n=6
Parse Time1.30s (± 0.63%)1.30s (± 0.31%)~1.30s1.31sp=0.584 n=6
Bind Time0.71s0.71s~~~p=1.000 n=6
Check Time9.48s (± 0.76%)9.48s (± 0.42%)~9.43s9.55sp=1.000 n=6
Emit Time2.76s (± 0.48%)2.97s (± 0.97%)🔻+0.21s (+ 7.67%)2.93s3.00sp=0.005 n=6
Total Time14.26s (± 0.51%)14.46s (± 0.40%)+0.21s (+ 1.46%)14.39s14.56sp=0.005 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols944,114944,114~~~p=1.000 n=6
Types407,050407,050~~~p=1.000 n=6
Memory used1,218,405k (± 0.00%)1,218,378k (± 0.01%)~1,218,270k1,218,499kp=0.378 n=6
Parse Time6.69s (± 0.57%)6.73s (± 0.77%)~6.66s6.82sp=0.418 n=6
Bind Time1.88s (± 0.67%)1.88s (± 0.43%)~1.87s1.89sp=0.558 n=6
Check Time30.61s (± 0.24%)30.71s (± 0.49%)~30.53s30.89sp=0.295 n=6
Emit Time13.59s (± 0.91%)13.60s (± 0.42%)~13.55s13.68sp=0.686 n=6
Total Time52.78s (± 0.36%)52.91s (± 0.40%)~52.69s53.28sp=0.378 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,130,2962,130,291-5 (- 0.00%)~~p=0.001 n=6
Types927,656927,643-13 (- 0.00%)~~p=0.001 n=6
Memory used2,107,060k (± 0.01%)2,107,028k (± 0.00%)~2,106,977k2,107,102kp=0.810 n=6
Parse Time6.62s (± 0.30%)6.61s (± 0.23%)~6.59s6.63sp=1.000 n=6
Bind Time2.33s (± 0.70%)2.32s (± 0.47%)~2.30s2.33sp=0.622 n=6
Check Time70.41s (± 0.75%)70.72s (± 0.40%)~70.35s71.07sp=0.336 n=6
Emit Time0.14s (± 2.95%)0.14s (± 4.51%)~0.13s0.15sp=0.673 n=6
Total Time79.49s (± 0.64%)79.79s (± 0.35%)~79.40s80.12sp=0.378 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,226,0051,226,072+67 (+ 0.01%)~~p=0.001 n=6
Types261,615261,670+55 (+ 0.02%)~~p=0.001 n=6
Memory used2,339,381k (± 0.03%)2,339,575k (± 0.02%)~2,339,026k2,340,123kp=0.378 n=6
Parse Time6.06s (± 0.71%)6.07s (± 1.29%)~6.00s6.20sp=0.810 n=6
Bind Time2.24s (± 0.56%)2.24s (± 0.56%)~2.23s2.26sp=0.934 n=6
Check Time40.34s (± 0.27%)40.19s (± 0.38%)~40.01s40.40sp=0.128 n=6
Emit Time3.86s (± 2.14%)3.85s (± 0.91%)~3.78s3.87sp=0.936 n=6
Total Time52.51s (± 0.27%)52.37s (± 0.30%)~52.13s52.56sp=0.230 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,226,0051,226,072+67 (+ 0.01%)~~p=0.001 n=6
Types261,615261,670+55 (+ 0.02%)~~p=0.001 n=6
Memory used2,413,110k (± 0.02%)2,413,066k (± 0.02%)~2,412,040k2,413,566kp=0.471 n=6
Parse Time5.25s (± 0.55%)5.24s (± 0.79%)~5.19s5.31sp=0.575 n=6
Bind Time1.68s (± 0.50%)1.69s (± 0.95%)~1.67s1.71sp=0.667 n=6
Check Time34.64s (± 0.21%)34.61s (± 0.12%)~34.55s34.65sp=0.335 n=6
Emit Time3.28s (± 1.59%)3.29s (± 1.16%)~3.24s3.33sp=0.630 n=6
Total Time44.87s (± 0.33%)44.82s (± 0.14%)~44.74s44.91sp=0.630 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols258,315258,380+65 (+ 0.03%)~~p=0.001 n=6
Types104,817104,863+46 (+ 0.04%)~~p=0.001 n=6
Memory used427,248k (± 0.03%)427,452k (± 0.03%)+204k (+ 0.05%)427,294k427,650kp=0.045 n=6
Parse Time3.31s (± 0.55%)3.31s (± 0.52%)~3.29s3.33sp=0.931 n=6
Bind Time1.31s (± 1.01%)1.32s (± 0.93%)~1.29s1.32sp=0.673 n=6
Check Time17.81s (± 0.21%)17.84s (± 0.28%)~17.77s17.90sp=0.294 n=6
Emit Time1.65s (± 0.54%)1.63s (± 0.55%)-0.02s (- 1.21%)1.62s1.64sp=0.011 n=6
Total Time24.09s (± 0.16%)24.10s (± 0.29%)~24.00s24.17sp=0.688 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,565224,568+3 (+ 0.00%)~~p=0.001 n=6
Types93,73493,738+4 (+ 0.00%)~~p=0.001 n=6
Memory used369,536k (± 0.02%)369,537k (± 0.02%)~369,425k369,685kp=1.000 n=6
Parse Time3.42s (± 1.05%)3.46s (± 1.08%)~3.40s3.50sp=0.198 n=6
Bind Time1.94s (± 0.73%)1.95s (± 0.79%)~1.93s1.96sp=0.276 n=6
Check Time19.17s (± 0.38%)19.19s (± 0.29%)~19.15s19.30sp=0.630 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time24.53s (± 0.34%)24.59s (± 0.33%)~24.49s24.72sp=0.335 n=6
vscode - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,889,8722,889,874+2 (+ 0.00%)~~p=0.001 n=6
Types977,787977,791+4 (+ 0.00%)~~p=0.001 n=6
Memory used3,053,447k (± 0.00%)3,053,475k (± 0.00%)~3,053,403k3,053,544kp=0.689 n=6
Parse Time16.90s (± 0.51%)16.83s (± 0.38%)~16.77s16.94sp=0.146 n=6
Bind Time5.12s (± 0.40%)5.11s (± 0.42%)~5.08s5.14sp=0.252 n=6
Check Time91.37s (± 2.95%)92.13s (± 2.26%)~89.55s94.56sp=0.575 n=6
Emit Time27.68s (± 9.12%)27.10s (± 7.87%)~24.40s29.46sp=0.689 n=6
Total Time141.07s (± 0.25%)141.16s (± 0.37%)~140.52s142.03sp=0.936 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols267,239267,239~~~p=1.000 n=6
Types108,815108,815~~~p=1.000 n=6
Memory used411,833k (± 0.02%)411,847k (± 0.02%)~411,730k411,957kp=0.936 n=6
Parse Time4.73s (± 0.19%)4.76s (± 0.48%)+0.03s (+ 0.63%)4.74s4.80sp=0.011 n=6
Bind Time2.08s (± 1.11%)2.09s (± 0.84%)~2.07s2.11sp=0.408 n=6
Check Time20.71s (± 0.41%)20.74s (± 0.30%)~20.68s20.82sp=0.470 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time27.52s (± 0.34%)27.60s (± 0.29%)~27.50s27.71sp=0.228 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols510,475510,475~~~p=1.000 n=6
Types161,600161,600~~~p=1.000 n=6
Memory used448,046k (± 0.06%)448,001k (± 0.08%)~447,591k448,395kp=1.000 n=6
Parse Time3.14s (± 1.06%)3.12s (± 0.48%)~3.11s3.15sp=0.466 n=6
Bind Time1.17s (± 0.64%)1.17s (± 0.35%)~1.17s1.18sp=1.000 n=6
Check Time16.95s (± 0.58%)16.99s (± 0.55%)~16.86s17.13sp=0.520 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time21.26s (± 0.50%)21.28s (± 0.46%)~21.15s21.44sp=0.688 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@danvk

Copy link
Copy Markdown
ContributorAuthor

Other than the compiler-unions emit time, this looks like ~0 impact. I can take a look at whether there's some giant type predicate being emitted that would account for that, but I'm skeptical since we didn't see change in this number back in April and the behavior of the PR shouldn't be different.

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/58154/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@danvk@jakebailey@typescript-bot@anka-213@RyanCavanaugh