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

Bailout early from isFunctionObjectType for evolving arrays #58049

Merged
merged 5 commits into from
Jul 26, 2024

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Apr 3, 2024

fixes #44659

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Apr 3, 2024
@@ -27044,6 27044,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function isFunctionObjectType(type: ObjectType): boolean {
if (getObjectFlags(type) & ObjectFlags.EvolvingArray) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolveStructuredTypeMembers is still going to crash if an evolving array manages to reach it. I concluded that it's still better - at least in this case - to bail out early. IIUC, it avoid "fixing" this evolving type without a strong reason to do so - so the evolving array can continue evolving in certain situations.

Copy link
Member

Choose a reason for hiding this comment

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

Are there other paths whereby an evolving array could reach resolveStructuredTypeMembers? This seems like an important limitation that needs to be checked, either multiple places or maybe within resolveStructuredTypeMembers itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are there other paths whereby an evolving array could reach resolveStructuredTypeMembers?

None that we are aware of. Any call with an evolving array to that function would throw and I didn't see any other crashes reported there. It's of course not completely unlikely that there are other ways to end up with that crash.

This seems like an important limitation that needs to be checked, either multiple places or maybe within resolveStructuredTypeMembers itself.

There is already an assert there. The only thing that potentially could be improved is to switch the assert to some other logic that would handle evolving arrays gracefully. I don't know what that logic would be and I think if this crash is a rare one then this fix is good enough.

@jakebailey
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 3, 2024

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

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

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,702k (± 0.01%) 295,708k (± 0.01%) ~ 295,676k 295,745k p=0.809 n=6
Parse Time 2.66s (± 0.31%) 2.65s (± 0.55%) ~ 2.63s 2.67s p=0.591 n=6
Bind Time 0.83s (± 0.49%) 0.83s (± 1.24%) ~ 0.82s 0.85s p=0.924 n=6
Check Time 8.28s (± 0.33%) 8.26s (± 0.30%) ~ 8.24s 8.31s p=0.284 n=6
Emit Time 7.03s (± 0.21%) 7.05s (± 0.31%) ~ 7.01s 7.07s p=0.089 n=6
Total Time 18.79s (± 0.13%) 18.80s (± 0.18%) ~ 18.74s 18.83s p=0.570 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 192,679k (± 0.72%) 192,722k (± 0.75%) ~ 192,000k 195,671k p=1.000 n=6
Parse Time 1.36s (± 1.20%) 1.36s (± 1.23%) ~ 1.34s 1.38s p=1.000 n=6
Bind Time 0.73s (± 0.00%) 0.73s (± 0.56%) ~ 0.72s 0.73s p=0.405 n=6
Check Time 9.56s (± 0.73%) 9.52s (± 0.22%) ~ 9.50s 9.55s p=0.260 n=6
Emit Time 2.63s (± 0.29%) 2.63s (± 0.40%) ~ 2.62s 2.65s p=0.273 n=6
Total Time 14.27s (± 0.51%) 14.24s (± 0.17%) ~ 14.20s 14.26s p=0.573 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,424k (± 0.01%) 347,432k (± 0.01%) ~ 347,406k 347,453k p=0.630 n=6
Parse Time 3.70s (± 0.43%) 3.67s (± 1.55%) ~ 3.56s 3.71s p=0.331 n=6
Bind Time 1.38s (± 0.37%) 1.38s (± 0.30%) ~ 1.37s 1.38s p=0.595 n=6
Check Time 10.18s (± 0.53%) 10.21s (± 0.33%) ~ 10.17s 10.26s p=0.289 n=6
Emit Time 6.03s (± 0.53%) 6.02s (± 0.09%) ~ 6.02s 6.03s p=0.866 n=6
Total Time 21.29s (± 0.24%) 21.28s (± 0.34%) ~ 21.17s 21.37s p=0.872 n=6
TFS - node (v18.15.0, x64)
Memory used 302,803k (± 0.01%) 302,799k (± 0.01%) ~ 302,755k 302,825k p=1.000 n=6
Parse Time 2.98s (± 1.29%) 2.96s (± 0.95%) ~ 2.92s 3.00s p=0.627 n=6
Bind Time 1.48s (± 0.99%) 1.47s (± 0.55%) ~ 1.46s 1.48s p=0.230 n=6
Check Time 9.24s (± 0.46%) 9.26s (± 0.24%) ~ 9.23s 9.30s p=0.370 n=6
Emit Time 5.32s (± 0.76%) 5.31s (± 0.65%) ~ 5.28s 5.37s p=0.744 n=6
Total Time 19.01s (± 0.44%) 19.01s (± 0.31%) ~ 18.93s 19.09s p=0.936 n=6
material-ui - node (v18.15.0, x64)
Memory used 510,050k (± 0.01%) 510,043k (± 0.01%) ~ 510,016k 510,095k p=0.575 n=6
Parse Time 2.66s (± 0.34%) 2.67s (± 0.31%) ~ 2.65s 2.67s p=0.339 n=6
Bind Time 0.99s (± 1.74%) 0.99s (± 1.11%) ~ 0.97s 1.00s p=0.933 n=6
Check Time 17.32s (± 0.40%) 17.34s (± 0.32%) ~ 17.30s 17.43s p=0.936 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.97s (± 0.37%) 21.00s (± 0.28%) ~ 20.95s 21.09s p=0.936 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,744,969k (± 0.00%) 1,744,962k (± 0.00%) ~ 1,744,920k 1,744,988k p=0.689 n=6
Parse Time 9.64s (± 0.70%) 9.59s (± 0.29%) ~ 9.56s 9.64s p=0.226 n=6
Bind Time 3.44s (± 0.63%) 3.45s (± 0.40%) ~ 3.43s 3.46s p=1.000 n=6
Check Time 81.64s (± 0.45%) 81.74s (± 0.18%) ~ 81.53s 81.89s p=1.000 n=6
Emit Time 0.19s (± 2.67%) 0.19s (± 2.13%) ~ 0.19s 0.20s p=0.595 n=6
Total Time 94.91s (± 0.37%) 94.97s (± 0.17%) ~ 94.74s 95.12s p=0.810 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,400,032k (± 0.04%) 2,400,431k (± 0.04%) ~ 2,399,214k 2,401,568k p=0.689 n=6
Parse Time 6.03s (± 0.99%) 6.01s (± 0.91%) ~ 5.94s 6.08s p=0.748 n=6
Bind Time 2.26s (± 1.23%) 2.26s (± 0.33%) ~ 2.25s 2.27s p=0.624 n=6
Check Time 39.88s (± 0.18%) 39.97s (± 0.54%) ~ 39.69s 40.24s p=0.748 n=6
Emit Time 3.19s (± 1.60%) 3.26s (± 3.71%) ~ 3.15s 3.49s p=0.261 n=6
Total Time 51.36s (± 0.15%) 51.50s (± 0.59%) ~ 51.09s 51.90s p=0.378 n=6
self-compiler - node (v18.15.0, x64)
Memory used 416,123k (± 0.00%) 416,146k (± 0.01%) ~ 416,092k 416,232k p=0.873 n=6
Parse Time 2.77s (± 0.59%) 2.75s (± 0.70%) ~ 2.73s 2.78s p=0.251 n=6
Bind Time 1.08s (± 0.76%) 1.08s (± 0.76%) ~ 1.07s 1.09s p=0.787 n=6
Check Time 15.41s (± 0.12%) 15.38s (± 0.41%) ~ 15.31s 15.46s p=0.747 n=6
Emit Time 1.11s (± 0.94%) 1.13s (± 2.15%) ~ 1.10s 1.17s p=0.413 n=6
Total Time 20.37s (± 0.08%) 20.33s (± 0.36%) ~ 20.23s 20.42s p=0.462 n=6
vscode - node (v18.15.0, x64)
Memory used 2,900,631k (± 0.00%) 2,900,624k (± 0.00%) ~ 2,900,520k 2,900,664k p=0.521 n=6
Parse Time 15.95s (± 0.56%) 15.97s (± 0.34%) ~ 15.92s 16.07s p=1.000 n=6
Bind Time 5.07s (± 0.51%) 5.05s (± 0.44%) ~ 5.02s 5.08s p=0.294 n=6
Check Time 87.99s (± 0.53%) 87.87s (± 0.68%) ~ 87.12s 88.83s p=0.810 n=6
Emit Time 24.45s (± 7.81%) 25.31s (± 9.42%) ~ 23.60s 28.44s p=0.336 n=6
Total Time 133.47s (± 1.49%) 134.19s (± 2.13%) ~ 131.87s 138.23s p=0.936 n=6
webpack - node (v18.15.0, x64)
Memory used 408,999k (± 0.02%) 408,957k (± 0.02%) ~ 408,807k 409,104k p=0.471 n=6
Parse Time 4.81s (± 0.78%) 4.81s (± 0.83%) ~ 4.75s 4.86s p=0.935 n=6
Bind Time 2.06s (± 0.51%) 2.06s (± 0.81%) ~ 2.04s 2.09s p=0.405 n=6
Check Time 20.91s (± 0.29%) 20.91s (± 0.56%) ~ 20.79s 21.10s p=0.810 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 27.79s (± 0.31%) 27.78s (± 0.42%) ~ 27.64s 27.96s p=0.936 n=6
xstate - node (v18.15.0, x64)
Memory used 513,586k (± 0.03%) 513,534k (± 0.02%) ~ 513,417k 513,653k p=0.471 n=6
Parse Time 4.90s (± 0.65%) 4.89s (± 0.95%) ~ 4.80s 4.93s p=0.805 n=6
Bind Time 2.31s (± 1.06%) 2.29s (± 0.75%) ~ 2.27s 2.32s p=0.163 n=6
Check Time 4.31s (± 1.05%) 4.31s (± 0.50%) ~ 4.29s 4.35s p=0.373 n=6
Emit Time 0.11s (± 0.00%) 0.11s (± 0.00%) ~ 0.11s 0.11s p=1.000 n=6
Total Time 11.62s (± 0.58%) 11.60s (± 0.34%) ~ 11.52s 11.62s p=0.630 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-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests comparing main and refs/pull/58049/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos comparing main and refs/pull/58049/merge:

Everything looks good!

@jakebailey jakebailey merged commit 1da9630 into microsoft:main Jul 26, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Status: Done
6 participants