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

Defer indexed accesses on generic potential discriminants #49274

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

weswigham
Copy link
Member

The issue was that {id: ID} & ({id: "yes", ...} | {id: "no", ...}) didn't register as an object type indexed accesses needed to be deferred on. Since instantiating ID could discriminate the type upon instantiation, and thus change what types are indexed into, the indexing operation must be deferred, as with other more traditional generic object types.

Fixes #45560

@weswigham weswigham requested a review from ahejlsberg May 26, 2022 22:10
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels May 26, 2022
@weswigham
Copy link
Member Author

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 15, 2022

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 15, 2022

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 15, 2022

Heya @weswigham, I've started to run the diff-based user code test suite on this PR at b6ee4f8. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 15, 2022

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 15, 2022

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@weswigham
Great news! no new errors were found between main..refs/pull/49274/merge

@weswigham weswigham requested a review from sandersn June 15, 2022 18:55
@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..49274

Metric main 49274 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 359,077k (± 0.03%) 359,325k (± 0.02%) +249k (+ 0.07%) 359,150k 359,461k
Parse Time 2.12s (± 0.53%) 2.11s (± 0.52%) -0.01s (- 0.28%) 2.09s 2.15s
Bind Time 0.90s (± 0.83%) 0.90s (± 1.91%) 0.00s ( 0.00%) 0.89s 0.97s
Check Time 5.97s (± 0.63%) 5.96s (± 0.52%) -0.01s (- 0.17%) 5.87s 6.03s
Emit Time 6.11s (± 0.96%) 6.11s (± 0.71%) -0.00s (- 0.05%) 6.04s 6.23s
Total Time 15.10s (± 0.58%) 15.08s (± 0.57%) -0.01s (- 0.10%) 14.92s 15.34s
Compiler-Unions - node (v10.16.3, x64)
Memory used 206,402k (± 0.04%) 206,524k (± 0.03%) +122k (+ 0.06%) 206,394k 206,675k
Parse Time 0.85s (± 1.12%) 0.84s (± 0.44%) -0.00s (- 0.12%) 0.84s 0.85s
Bind Time 0.53s (± 1.22%) 0.53s (± 1.59%) -0.00s (- 0.19%) 0.52s 0.56s
Check Time 8.19s (± 0.63%) 8.24s (± 0.55%) +0.05s (+ 0.56%) 8.12s 8.33s
Emit Time 2.52s (± 0.89%) 2.50s (± 0.73%) -0.02s (- 0.91%) 2.46s 2.53s
Total Time 12.09s (± 0.56%) 12.11s (± 0.35%) +0.02s (+ 0.16%) 12.01s 12.20s
Monaco - node (v10.16.3, x64)
Memory used 343,787k (± 0.03%) 343,809k (± 0.01%) +22k (+ 0.01%) 343,699k 343,938k
Parse Time 1.61s (± 0.66%) 1.61s (± 0.58%) -0.00s (- 0.25%) 1.59s 1.63s
Bind Time 0.77s (± 0.75%) 0.77s (± 0.47%) +0.00s (+ 0.52%) 0.77s 0.78s
Check Time 5.96s (± 0.45%) 5.99s (± 0.49%) +0.03s (+ 0.54%) 5.93s 6.06s
Emit Time 3.25s (± 0.47%) 3.25s (± 0.89%) -0.01s (- 0.25%) 3.17s 3.32s
Total Time 11.60s (± 0.23%) 11.62s (± 0.42%) +0.02s (+ 0.16%) 11.52s 11.74s
TFS - node (v10.16.3, x64)
Memory used 305,142k (± 0.02%) 305,055k (± 0.02%) -87k (- 0.03%) 304,929k 305,223k
Parse Time 1.31s (± 0.85%) 1.30s (± 0.46%) -0.00s (- 0.15%) 1.29s 1.32s
Bind Time 0.73s (± 0.96%) 0.73s (± 0.68%) -0.00s (- 0.41%) 0.72s 0.74s
Check Time 5.42s (± 0.48%) 5.39s (± 0.80%) -0.02s (- 0.46%) 5.31s 5.47s
Emit Time 3.40s (± 1.08%) 3.43s (± 0.82%) +0.03s (+ 0.85%) 3.38s 3.52s
Total Time 10.85s (± 0.53%) 10.85s (± 0.60%) 0.00s ( 0.00%) 10.75s 11.02s
material-ui - node (v10.16.3, x64)
Memory used 469,093k (± 0.01%) 484,057k (± 0.01%) +14,964k (+ 3.19%) 483,873k 484,193k
Parse Time 1.87s (± 0.93%) 1.85s (± 0.60%) -0.01s (- 0.64%) 1.83s 1.89s
Bind Time 0.69s (± 1.19%) 0.69s (± 1.74%) +0.00s (+ 0.14%) 0.66s 0.71s
Check Time 14.61s (± 0.70%) 20.25s (± 0.59%) 🔻+5.64s (+38.63%) 19.98s 20.48s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 17.17s (± 0.60%) 22.80s (± 0.55%) 🔻+5.63s (+32.81%) 22.52s 23.04s
xstate - node (v10.16.3, x64)
Memory used 577,446k (± 0.02%) 577,884k (± 0.01%) +438k (+ 0.08%) 577,738k 578,008k
Parse Time 2.64s (± 0.25%) 2.63s (± 0.47%) -0.01s (- 0.30%) 2.61s 2.67s
Bind Time 1.05s (± 0.57%) 1.04s (± 0.38%) -0.00s (- 0.38%) 1.03s 1.05s
Check Time 1.54s (± 0.71%) 1.57s (± 0.81%) +0.03s (+ 2.21%) 1.54s 1.60s
Emit Time 0.07s (± 3.14%) 0.07s (± 0.00%) -0.00s (- 1.41%) 0.07s 0.07s
Total Time 5.29s (± 0.33%) 5.31s (± 0.30%) +0.02s (+ 0.36%) 5.28s 5.35s
Angular - node (v12.1.0, x64)
Memory used 336,751k (± 0.02%) 336,933k (± 0.03%) +182k (+ 0.05%) 336,642k 337,147k
Parse Time 2.10s (± 0.72%) 2.10s (± 1.00%) -0.00s (- 0.19%) 2.06s 2.13s
Bind Time 0.86s (± 0.46%) 0.85s (± 0.35%) -0.01s (- 1.05%) 0.85s 0.86s
Check Time 5.80s (± 0.39%) 5.84s (± 0.76%) +0.04s (+ 0.74%) 5.77s 5.99s
Emit Time 6.39s (± 0.74%) 6.38s (± 0.51%) -0.01s (- 0.08%) 6.32s 6.46s
Total Time 15.15s (± 0.38%) 15.18s (± 0.39%) +0.02s (+ 0.14%) 15.05s 15.29s
Compiler-Unions - node (v12.1.0, x64)
Memory used 193,786k (± 0.16%) 194,147k (± 0.12%) +361k (+ 0.19%) 193,538k 194,431k
Parse Time 0.84s (± 0.97%) 0.83s (± 0.41%) -0.01s (- 1.19%) 0.83s 0.84s
Bind Time 0.55s (± 1.58%) 0.55s (± 1.01%) 0.00s ( 0.00%) 0.54s 0.56s
Check Time 7.63s (± 0.60%) 7.67s (± 0.91%) +0.04s (+ 0.48%) 7.48s 7.78s
Emit Time 2.55s (± 1.27%) 2.53s (± 1.28%) -0.02s (- 0.78%) 2.47s 2.60s
Total Time 11.57s (± 0.53%) 11.58s (± 0.79%) +0.01s (+ 0.08%) 11.39s 11.75s
Monaco - node (v12.1.0, x64)
Memory used 326,822k (± 0.01%) 326,831k (± 0.02%) +9k (+ 0.00%) 326,740k 326,959k
Parse Time 1.58s (± 0.61%) 1.58s (± 0.76%) -0.00s (- 0.13%) 1.55s 1.61s
Bind Time 0.76s (± 0.62%) 0.75s (± 0.63%) -0.01s (- 0.92%) 0.74s 0.76s
Check Time 5.80s (± 0.54%) 5.78s (± 0.54%) -0.02s (- 0.36%) 5.70s 5.83s
Emit Time 3.31s (± 1.05%) 3.31s (± 0.70%) +0.00s (+ 0.03%) 3.27s 3.36s
Total Time 11.45s (± 0.52%) 11.42s (± 0.41%) -0.03s (- 0.25%) 11.30s 11.50s
TFS - node (v12.1.0, x64)
Memory used 289,747k (± 0.02%) 289,771k (± 0.02%) +24k (+ 0.01%) 289,646k 289,910k
Parse Time 1.31s (± 1.16%) 1.31s (± 0.87%) -0.01s (- 0.38%) 1.29s 1.35s
Bind Time 0.76s (± 0.88%) 0.75s (± 0.97%) -0.01s (- 1.19%) 0.74s 0.77s
Check Time 5.35s (± 0.45%) 5.34s (± 0.52%) -0.01s (- 0.17%) 5.27s 5.39s
Emit Time 3.54s (± 0.92%) 3.52s (± 0.52%) -0.02s (- 0.51%) 3.49s 3.58s
Total Time 10.96s (± 0.42%) 10.92s (± 0.32%) -0.04s (- 0.38%) 10.84s 10.98s
material-ui - node (v12.1.0, x64)
Memory used 448,102k (± 0.06%) 462,806k (± 0.06%) +14,705k (+ 3.28%) 461,782k 463,024k
Parse Time 1.86s (± 0.62%) 1.86s (± 0.70%) -0.00s (- 0.27%) 1.85s 1.91s
Bind Time 0.68s (± 0.72%) 0.68s (± 0.91%) -0.00s (- 0.44%) 0.67s 0.70s
Check Time 13.17s (± 0.58%) 17.62s (± 0.47%) 🔻+4.45s (+33.83%) 17.45s 17.80s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.72s (± 0.54%) 20.16s (± 0.46%) +4.45s (+28.30%) 19.98s 20.35s
xstate - node (v12.1.0, x64)
Memory used 543,116k (± 0.01%) 553,277k (± 2.00%) +10,162k (+ 1.87%) 543,173k 576,076k
Parse Time 2.58s (± 0.70%) 2.59s (± 0.59%) +0.01s (+ 0.46%) 2.56s 2.62s
Bind Time 1.04s (± 0.62%) 1.02s (± 0.58%) -0.01s (- 1.35%) 1.01s 1.04s
Check Time 1.50s (± 0.59%) 1.52s (± 0.74%) +0.02s (+ 1.40%) 1.50s 1.55s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.19s (± 0.54%) 5.21s (± 0.49%) +0.03s (+ 0.50%) 5.14s 5.27s
Angular - node (v14.15.1, x64)
Memory used 334,908k (± 0.01%) 335,091k (± 0.01%) +183k (+ 0.05%) 335,051k 335,125k
Parse Time 2.08s (± 0.72%) 2.08s (± 0.41%) -0.01s (- 0.29%) 2.06s 2.10s
Bind Time 0.90s (± 0.53%) 0.90s (± 0.38%) 0.00s ( 0.00%) 0.90s 0.91s
Check Time 5.76s (± 0.51%) 5.79s (± 0.28%) +0.03s (+ 0.50%) 5.75s 5.82s
Emit Time 6.47s (± 0.69%) 6.45s (± 0.54%) -0.02s (- 0.31%) 6.37s 6.53s
Total Time 15.22s (± 0.49%) 15.22s (± 0.28%) +0.01s (+ 0.05%) 15.14s 15.32s
Compiler-Unions - node (v14.15.1, x64)
Memory used 192,595k (± 0.01%) 192,781k (± 0.01%) +185k (+ 0.10%) 192,724k 192,842k
Parse Time 0.85s (± 0.70%) 0.85s (± 0.53%) -0.01s (- 0.70%) 0.84s 0.86s
Bind Time 0.58s (± 1.02%) 0.58s (± 0.95%) -0.00s (- 0.34%) 0.57s 0.59s
Check Time 7.71s (± 0.59%) 7.79s (± 0.48%) +0.08s (+ 1.04%) 7.71s 7.88s
Emit Time 2.53s (± 1.06%) 2.51s (± 0.70%) -0.02s (- 0.75%) 2.49s 2.58s
Total Time 11.68s (± 0.56%) 11.73s (± 0.28%) +0.05s (+ 0.44%) 11.68s 11.81s
Monaco - node (v14.15.1, x64)
Memory used 325,583k (± 0.00%) 325,597k (± 0.01%) +14k (+ 0.00%) 325,572k 325,640k
Parse Time 1.59s (± 0.74%) 1.59s (± 0.70%) -0.00s (- 0.25%) 1.56s 1.61s
Bind Time 0.79s (± 0.43%) 0.79s (± 0.51%) +0.00s (+ 0.25%) 0.78s 0.80s
Check Time 5.69s (± 0.48%) 5.67s (± 0.37%) -0.01s (- 0.21%) 5.63s 5.72s
Emit Time 3.38s (± 0.54%) 3.37s (± 1.14%) -0.01s (- 0.41%) 3.31s 3.49s
Total Time 11.44s (± 0.32%) 11.42s (± 0.51%) -0.03s (- 0.24%) 11.30s 11.56s
TFS - node (v14.15.1, x64)
Memory used 288,727k (± 0.01%) 288,731k (± 0.01%) +4k (+ 0.00%) 288,675k 288,784k
Parse Time 1.33s (± 0.86%) 1.34s (± 2.14%) +0.00s (+ 0.38%) 1.31s 1.44s
Bind Time 0.76s (± 0.29%) 0.75s (± 0.91%) -0.00s (- 0.53%) 0.74s 0.77s
Check Time 5.34s (± 0.39%) 5.32s (± 0.54%) -0.01s (- 0.22%) 5.27s 5.40s
Emit Time 3.58s (± 2.00%) 3.51s (± 1.33%) -0.07s (- 2.09%) 3.43s 3.67s
Total Time 11.01s (± 0.65%) 10.92s (± 0.52%) -0.09s (- 0.81%) 10.78s 11.03s
material-ui - node (v14.15.1, x64)
Memory used 446,425k (± 0.00%) 461,224k (± 0.06%) +14,800k (+ 3.32%) 460,200k 461,365k
Parse Time 1.90s (± 0.49%) 1.89s (± 0.67%) -0.01s (- 0.47%) 1.87s 1.92s
Bind Time 0.73s (± 1.24%) 0.73s (± 0.91%) -0.00s (- 0.14%) 0.71s 0.74s
Check Time 13.30s (± 0.83%) 17.66s (± 0.60%) 🔻+4.36s (+32.78%) 17.43s 17.91s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.93s (± 0.70%) 20.28s (± 0.55%) +4.35s (+27.29%) 20.03s 20.53s
xstate - node (v14.15.1, x64)
Memory used 540,837k (± 0.00%) 541,217k (± 0.00%) +380k (+ 0.07%) 541,171k 541,304k
Parse Time 2.63s (± 0.41%) 2.62s (± 0.68%) -0.01s (- 0.38%) 2.58s 2.67s
Bind Time 1.18s (± 1.38%) 1.18s (± 1.09%) -0.01s (- 0.51%) 1.15s 1.20s
Check Time 1.54s (± 0.69%) 1.57s (± 0.76%) +0.03s (+ 1.75%) 1.55s 1.60s
Emit Time 0.07s (± 4.66%) 0.07s (± 4.66%) 0.00s ( 0.00%) 0.07s 0.08s
Total Time 5.44s (± 0.55%) 5.44s (± 0.44%) +0.00s (+ 0.07%) 5.40s 5.49s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-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)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 49274 10
Baseline main 10

Developer Information:

Download Benchmark

@weswigham
Copy link
Member Author

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 15, 2022

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

Update: The results are in!

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.

Looks good. I have one question about partial properties and some optional formatting suggestions.

@@ -11934,6 +11934,10 @@ namespace ts {
});
}

/**
* Caution: Do you _really_ mean to use this fucntion? It creates fresh property symbols in an uncached manner - if you, the caller,
* do not cache the result of this function, you may have very poor performance over large unions.
Copy link
Member

Choose a reason for hiding this comment

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

is there a cached version, or at least a common way to cache its result? If so it would be good to mention that too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not quite? If you have a union, the property cache on the union serves a similar purpose. I added this comment because I'd used it in the first iteration, and it caused horrendous perf regressions because of the lack of caching it caused.

@@ -12315,6 +12319,10 @@ namespace ts {
return getReducedType(getApparentType(getReducedType(type)));
}

function isDiscriminableLiteralType(type: Type): boolean {
return isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType || (!!(type.flags & TypeFlags.Intersection) && some((type as IntersectionType).types, isDiscriminableLiteralType));
Copy link
Member

Choose a reason for hiding this comment

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

I would break the line here. It's too long to fit on any of my screens as-is.

Suggested change
return isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType || (!!(type.flags & TypeFlags.Intersection) && some((type as IntersectionType).types, isDiscriminableLiteralType));
return isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType
|| (!!(type.flags & TypeFlags.Intersection) && some((type as IntersectionType).types, isDiscriminableLiteralType));

@@ -26,19 +26,19 @@ type T01 = keyof Object;
>T01 : keyof Object

type T02 = keyof keyof Object;
>T02 : number | "length" | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "substr" | "valueOf"
Copy link
Member

Choose a reason for hiding this comment

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

wish we could come up with a fast way to sort union output =(

((prop as TransientSymbol).checkFlags & CheckFlags.Discriminant) === CheckFlags.Discriminant &&
!isGenericType(getTypeOfSymbol(prop));
((prop as TransientSymbol).checkFlags & CheckFlags.Discriminant) === CheckFlags.Discriminant ?
!isGenericType(getTypeOfSymbol(prop)) ? DiscriminantKind.Concrete : DiscriminantKind.Potential : DiscriminantKind.None;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
!isGenericType(getTypeOfSymbol(prop)) ? DiscriminantKind.Concrete : DiscriminantKind.Potential : DiscriminantKind.None;
isGenericType(getTypeOfSymbol(prop)) ? DiscriminantKind.Potential : DiscriminantKind.Concrete : DiscriminantKind.None;

Comment on lines +15691 to +15692
reduceLeft((type as UnionOrIntersectionType).types, (flags, t) => flags | getGenericObjectFlags(t), 0) |
(type.flags & TypeFlags.Union && isUnionWithGenericDiscriminantProperty(type as UnionType) ? ObjectFlags.IsGenericObjectType : 0);
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be easier to read if you flipped the line order. I got confused about whether the new line was inside the reduceLeft call or not.

Suggested change
reduceLeft((type as UnionOrIntersectionType).types, (flags, t) => flags | getGenericObjectFlags(t), 0) |
(type.flags & TypeFlags.Union && isUnionWithGenericDiscriminantProperty(type as UnionType) ? ObjectFlags.IsGenericObjectType : 0);
(type.flags & TypeFlags.Union && isUnionWithGenericDiscriminantProperty(type as UnionType) ? ObjectFlags.IsGenericObjectType : 0) |
reduceLeft((type as UnionOrIntersectionType).types, (flags, t) => flags | getGenericObjectFlags(t), 0);

src/compiler/checker.ts Show resolved Hide resolved
function isUnionWithGenericDiscriminantProperty(type: UnionType) {
getPropertiesOfType(type); // initialize property cache (includes partial props)
const props = arrayFrom((type.propertyCache || emptySymbols).values());
for (const prop of props) {
Copy link
Member

Choose a reason for hiding this comment

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

Is the for loop better than

return props.find(prop => isDiscriminantProperty(type, prop.escapeName) === DiscriminantKind.Potential)

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ehh... It probably can be if I swap the loop to using the iterator directly rather than collecting it, like it was thinking.

Copy link
Member

Choose a reason for hiding this comment

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

I thought we were switching to target ES6 sometime soon? At least, I'm pretty sure that would let us use for-of to iterate maps finally.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..49274

Metric main 49274 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 359,076k (± 0.02%) 359,240k (± 0.03%) +164k (+ 0.05%) 359,047k 359,551k
Parse Time 2.10s (± 0.36%) 2.10s (± 0.41%) -0.01s (- 0.33%) 2.08s 2.12s
Bind Time 0.90s (± 0.75%) 0.90s (± 0.89%) +0.00s (+ 0.11%) 0.89s 0.92s
Check Time 5.92s (± 0.45%) 5.96s (± 0.43%) +0.05s (+ 0.78%) 5.93s 6.05s
Emit Time 6.09s (± 0.46%) 6.09s (± 0.67%) +0.00s (+ 0.02%) 6.03s 6.23s
Total Time 15.01s (± 0.29%) 15.05s (± 0.28%) +0.04s (+ 0.27%) 14.99s 15.17s
Compiler-Unions - node (v10.16.3, x64)
Memory used 206,388k (± 0.04%) 206,570k (± 0.04%) +182k (+ 0.09%) 206,370k 206,753k
Parse Time 0.83s (± 1.06%) 0.83s (± 1.06%) 0.00s ( 0.00%) 0.81s 0.85s
Bind Time 0.53s (± 1.37%) 0.53s (± 1.32%) -0.00s (- 0.56%) 0.52s 0.55s
Check Time 8.09s (± 0.67%) 8.17s (± 0.71%) +0.08s (+ 1.03%) 8.07s 8.34s
Emit Time 2.50s (± 0.72%) 2.48s (± 0.72%) -0.02s (- 0.64%) 2.44s 2.52s
Total Time 11.95s (± 0.55%) 12.01s (± 0.52%) +0.07s (+ 0.54%) 11.87s 12.19s
Monaco - node (v10.16.3, x64)
Memory used 343,742k (± 0.03%) 343,763k (± 0.02%) +21k (+ 0.01%) 343,537k 343,945k
Parse Time 1.59s (± 0.62%) 1.59s (± 0.37%) -0.01s (- 0.31%) 1.58s 1.60s
Bind Time 0.77s (± 0.62%) 0.77s (± 0.95%) +0.00s (+ 0.13%) 0.75s 0.78s
Check Time 5.96s (± 0.48%) 5.97s (± 0.49%) +0.01s (+ 0.15%) 5.89s 6.03s
Emit Time 3.23s (± 0.34%) 3.24s (± 0.59%) +0.01s (+ 0.34%) 3.21s 3.30s
Total Time 11.55s (± 0.27%) 11.56s (± 0.39%) +0.01s (+ 0.13%) 11.44s 11.69s
TFS - node (v10.16.3, x64)
Memory used 305,153k (± 0.02%) 305,140k (± 0.02%) -13k (- 0.00%) 304,990k 305,293k
Parse Time 1.29s (± 0.63%) 1.30s (± 0.53%) +0.01s (+ 0.47%) 1.28s 1.31s
Bind Time 0.73s (± 0.61%) 0.72s (± 0.50%) -0.00s (- 0.55%) 0.72s 0.73s
Check Time 5.38s (± 0.64%) 5.40s (± 0.56%) +0.01s (+ 0.24%) 5.34s 5.46s
Emit Time 3.42s (± 1.50%) 3.43s (± 1.30%) +0.01s (+ 0.35%) 3.36s 3.59s
Total Time 10.82s (± 0.46%) 10.85s (± 0.53%) +0.03s (+ 0.26%) 10.77s 11.05s
material-ui - node (v10.16.3, x64)
Memory used 469,156k (± 0.02%) 479,090k (± 0.01%) +9,933k (+ 2.12%) 478,907k 479,235k
Parse Time 1.84s (± 0.50%) 1.85s (± 0.55%) +0.00s (+ 0.22%) 1.82s 1.86s
Bind Time 0.69s (± 1.58%) 0.70s (± 1.00%) +0.01s (+ 1.30%) 0.69s 0.72s
Check Time 14.47s (± 0.49%) 17.00s (± 0.44%) +2.53s (+17.52%) 16.83s 17.13s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 17.01s (± 0.43%) 19.55s (± 0.37%) +2.54s (+14.97%) 19.39s 19.67s
xstate - node (v10.16.3, x64)
Memory used 577,468k (± 0.01%) 581,014k (± 1.26%) +3,547k (+ 0.61%) 577,590k 610,670k
Parse Time 2.62s (± 0.35%) 2.63s (± 0.44%) +0.01s (+ 0.27%) 2.60s 2.65s
Bind Time 1.04s (± 0.93%) 1.03s (± 0.71%) -0.01s (- 0.67%) 1.02s 1.05s
Check Time 1.53s (± 0.49%) 1.55s (± 0.42%) +0.02s (+ 1.17%) 1.54s 1.57s
Emit Time 0.07s (± 3.14%) 0.07s (± 3.14%) 0.00s ( 0.00%) 0.07s 0.08s
Total Time 5.26s (± 0.22%) 5.28s (± 0.41%) +0.01s (+ 0.25%) 5.24s 5.33s
Angular - node (v12.1.0, x64)
Memory used 336,758k (± 0.01%) 336,813k (± 0.09%) +55k (+ 0.02%) 335,597k 337,165k
Parse Time 2.08s (± 0.56%) 2.09s (± 0.76%) +0.01s (+ 0.48%) 2.05s 2.12s
Bind Time 0.85s (± 0.58%) 0.86s (± 0.78%) +0.00s (+ 0.35%) 0.84s 0.87s
Check Time 5.78s (± 0.14%) 5.79s (± 0.63%) +0.01s (+ 0.21%) 5.72s 5.87s
Emit Time 6.37s (± 0.62%) 6.39s (± 0.61%) +0.02s (+ 0.35%) 6.32s 6.51s
Total Time 15.09s (± 0.33%) 15.13s (± 0.45%) +0.05s (+ 0.30%) 14.98s 15.30s
Compiler-Unions - node (v12.1.0, x64)
Memory used 194,107k (± 0.04%) 194,229k (± 0.04%) +122k (+ 0.06%) 194,076k 194,379k
Parse Time 0.83s (± 0.80%) 0.82s (± 0.41%) -0.01s (- 0.84%) 0.82s 0.83s
Bind Time 0.54s (± 0.74%) 0.55s (± 1.27%) +0.01s (+ 1.85%) 0.54s 0.57s
Check Time 7.56s (± 0.72%) 7.64s (± 0.73%) +0.08s (+ 1.00%) 7.50s 7.73s
Emit Time 2.53s (± 1.14%) 2.53s (± 0.85%) -0.00s (- 0.08%) 2.48s 2.59s
Total Time 11.46s (± 0.73%) 11.54s (± 0.60%) +0.07s (+ 0.61%) 11.36s 11.69s
Monaco - node (v12.1.0, x64)
Memory used 326,865k (± 0.02%) 326,857k (± 0.03%) -8k (- 0.00%) 326,650k 327,067k
Parse Time 1.56s (± 0.81%) 1.56s (± 0.91%) -0.00s (- 0.26%) 1.53s 1.59s
Bind Time 0.76s (± 0.73%) 0.76s (± 0.62%) +0.00s (+ 0.26%) 0.75s 0.77s
Check Time 5.76s (± 0.38%) 5.77s (± 0.45%) +0.01s (+ 0.17%) 5.70s 5.81s
Emit Time 3.28s (± 0.75%) 3.28s (± 0.68%) -0.01s (- 0.15%) 3.24s 3.34s
Total Time 11.36s (± 0.37%) 11.36s (± 0.43%) +0.00s (+ 0.01%) 11.27s 11.49s
TFS - node (v12.1.0, x64)
Memory used 289,708k (± 0.01%) 289,727k (± 0.03%) +19k (+ 0.01%) 289,526k 289,932k
Parse Time 1.30s (± 0.78%) 1.30s (± 1.31%) -0.00s (- 0.00%) 1.26s 1.35s
Bind Time 0.77s (± 2.05%) 0.76s (± 1.08%) -0.01s (- 1.56%) 0.74s 0.78s
Check Time 5.31s (± 0.36%) 5.29s (± 0.37%) -0.02s (- 0.30%) 5.25s 5.34s
Emit Time 3.51s (± 0.43%) 3.51s (± 0.96%) +0.01s (+ 0.20%) 3.42s 3.59s
Total Time 10.89s (± 0.32%) 10.86s (± 0.42%) -0.02s (- 0.21%) 10.76s 10.96s
material-ui - node (v12.1.0, x64)
Memory used 448,030k (± 0.07%) 457,909k (± 0.08%) +9,879k (+ 2.21%) 456,960k 458,249k
Parse Time 1.85s (± 0.47%) 1.84s (± 0.63%) -0.00s (- 0.27%) 1.82s 1.87s
Bind Time 0.68s (± 0.95%) 0.68s (± 0.65%) 0.00s ( 0.00%) 0.67s 0.69s
Check Time 13.08s (± 0.89%) 15.16s (± 0.60%) +2.09s (+15.97%) 14.96s 15.31s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.60s (± 0.74%) 17.69s (± 0.56%) +2.09s (+13.37%) 17.47s 17.85s
xstate - node (v12.1.0, x64)
Memory used 549,625k (± 1.74%) 543,304k (± 0.02%) -6,321k (- 1.15%) 543,047k 543,489k
Parse Time 2.58s (± 0.53%) 2.57s (± 0.37%) -0.01s (- 0.39%) 2.55s 2.59s
Bind Time 1.04s (± 1.35%) 1.05s (± 1.63%) +0.01s (+ 0.77%) 1.02s 1.08s
Check Time 1.49s (± 0.54%) 1.50s (± 0.59%) +0.01s (+ 0.87%) 1.49s 1.53s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.18s (± 0.37%) 5.19s (± 0.43%) +0.01s (+ 0.23%) 5.14s 5.23s
Angular - node (v14.15.1, x64)
Memory used 334,890k (± 0.00%) 335,040k (± 0.01%) +150k (+ 0.04%) 334,983k 335,126k
Parse Time 2.07s (± 0.34%) 2.08s (± 0.51%) +0.01s (+ 0.34%) 2.06s 2.10s
Bind Time 0.90s (± 0.38%) 0.90s (± 0.53%) 0.00s ( 0.00%) 0.90s 0.92s
Check Time 5.77s (± 0.68%) 5.76s (± 0.44%) -0.01s (- 0.21%) 5.70s 5.81s
Emit Time 6.46s (± 0.61%) 6.41s (± 0.75%) -0.05s (- 0.79%) 6.33s 6.51s
Total Time 15.20s (± 0.45%) 15.15s (± 0.47%) -0.05s (- 0.35%) 15.01s 15.27s
Compiler-Unions - node (v14.15.1, x64)
Memory used 192,599k (± 0.02%) 192,758k (± 0.01%) +160k (+ 0.08%) 192,711k 192,814k
Parse Time 0.84s (± 0.66%) 0.84s (± 0.69%) -0.00s (- 0.12%) 0.83s 0.85s
Bind Time 0.58s (± 0.77%) 0.58s (± 0.00%) +0.00s (+ 0.35%) 0.58s 0.58s
Check Time 7.65s (± 0.63%) 7.66s (± 0.35%) +0.01s (+ 0.12%) 7.59s 7.71s
Emit Time 2.54s (± 0.98%) 2.53s (± 1.32%) -0.01s (- 0.39%) 2.48s 2.61s
Total Time 11.61s (± 0.47%) 11.61s (± 0.45%) -0.00s (- 0.03%) 11.53s 11.73s
Monaco - node (v14.15.1, x64)
Memory used 325,581k (± 0.01%) 325,573k (± 0.01%) -8k (- 0.00%) 325,510k 325,597k
Parse Time 1.58s (± 1.08%) 1.57s (± 0.85%) -0.01s (- 0.95%) 1.55s 1.60s
Bind Time 0.80s (± 0.75%) 0.79s (± 0.66%) -0.01s (- 0.88%) 0.78s 0.80s
Check Time 5.67s (± 0.57%) 5.68s (± 0.53%) +0.01s (+ 0.16%) 5.62s 5.77s
Emit Time 3.35s (± 0.84%) 3.37s (± 0.84%) +0.02s (+ 0.51%) 3.33s 3.44s
Total Time 11.40s (± 0.54%) 11.40s (± 0.51%) +0.00s (+ 0.04%) 11.30s 11.57s
TFS - node (v14.15.1, x64)
Memory used 288,728k (± 0.01%) 288,758k (± 0.01%) +30k (+ 0.01%) 288,709k 288,786k
Parse Time 1.33s (± 1.90%) 1.32s (± 1.27%) -0.02s (- 1.20%) 1.29s 1.36s
Bind Time 0.75s (± 1.15%) 0.76s (± 1.18%) +0.00s (+ 0.53%) 0.74s 0.77s
Check Time 5.31s (± 0.47%) 5.32s (± 0.38%) +0.02s (+ 0.32%) 5.29s 5.37s
Emit Time 3.58s (± 2.31%) 3.57s (± 2.01%) -0.01s (- 0.25%) 3.43s 3.70s
Total Time 10.97s (± 0.87%) 10.96s (± 0.70%) -0.01s (- 0.06%) 10.81s 11.13s
material-ui - node (v14.15.1, x64)
Memory used 446,353k (± 0.04%) 456,482k (± 0.01%) +10,130k (+ 2.27%) 456,417k 456,537k
Parse Time 1.89s (± 0.53%) 1.89s (± 0.47%) +0.00s (+ 0.05%) 1.88s 1.92s
Bind Time 0.73s (± 1.23%) 0.73s (± 0.67%) +0.01s (+ 1.10%) 0.72s 0.74s
Check Time 13.25s (± 0.87%) 15.25s (± 1.17%) +2.00s (+15.13%) 15.08s 15.85s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.87s (± 0.71%) 17.88s (± 1.02%) +2.01s (+12.68%) 17.70s 18.49s
xstate - node (v14.15.1, x64)
Memory used 540,824k (± 0.01%) 541,022k (± 0.00%) +198k (+ 0.04%) 540,998k 541,056k
Parse Time 2.62s (± 0.44%) 2.60s (± 0.32%) -0.01s (- 0.53%) 2.59s 2.62s
Bind Time 1.17s (± 1.17%) 1.19s (± 1.39%) +0.02s (+ 1.28%) 1.16s 1.23s
Check Time 1.54s (± 0.43%) 1.55s (± 0.56%) +0.01s (+ 0.72%) 1.53s 1.57s
Emit Time 0.07s (± 3.14%) 0.07s (± 3.14%) 0.00s ( 0.00%) 0.07s 0.08s
Total Time 5.40s (± 0.45%) 5.41s (± 0.40%) +0.01s (+ 0.17%) 5.36s 5.46s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-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)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 49274 10
Baseline main 10

Developer Information:

Download Benchmark

@ahejlsberg
Copy link
Member

Haven't looked at the code yet, but boy that's a pretty hefty perf hit in material-ui.

@weswigham
Copy link
Member Author

Awk, well, I just fixed half of it, hopefully the other half is mostly fixable, too, and just indicative of a lack of caching somewhere.

@@ -11934,6 +11934,10 @@ namespace ts {
});
}

/**
* Caution: Do you _really_ mean to use this fucntion? It creates fresh property symbols in an uncached manner - if you, the caller,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Caution: Do you _really_ mean to use this fucntion? It creates fresh property symbols in an uncached manner - if you, the caller,
* Caution: Do you _really_ mean to use this function? It creates fresh property symbols in an uncached manner - if you, the caller,

@sandersn
Copy link
Member

sandersn commented Dec 4, 2023

@weswigham Do you want to come back to fix the slower performance, or should we close this PR?

@weswigham weswigham marked this pull request as draft August 13, 2024 22:23
@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Milestone Bug PRs that fix a bug with a specific milestone labels Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Backlog Bug PRs that fix a backlog bug
Projects
Status: Waiting on author
Development

Successfully merging this pull request may close these issues.

Mapped types lose type information
5 participants