Fix perf regression from #42556#43949
Conversation
PR microsoft#42556 was a nice optimization that dramatically sped up comparisons of discriminated unions. Unfortunately, the cost of determining whether a union is discriminated can be prohibitively high. In particular, an internal team with a very large repo saw their type count double and their memory usage increase from 6GB to 9GB, breaking their build. This changes splits the difference by not trying to compute the property types of intersection types - a notoriously slow operation.
weswigham
left a comment
There was a problem hiding this comment.
IIRC, the fail case is not using this fast path for identifying which union member to compare to, so this seems fine; though it's maybe worth noting that changes to the input program (namely some more comparisons between types) could make it potentially bloom to this size anyway, since it's not like we were manifesting anything that might not have been made manifest for other checks.
|
@weswigham I think you're pointing out that this will slow down some compilations (those that would have tugged on the properties anyway and were using discriminated unions), but only to the performance they were at before #42556. Did I get that right? |
|
Yeah. |
|
@typescript-bot perf test this |
|
Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at abfa620. You can monitor the build here. Update: The results are in! |
|
@ahejlsberg we'd like to land this for the RC in case you want to take a quick look. |
|
@DanielRosenwasser Here they are:Comparison Report - master..43949
System
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PR #42556 was a nice optimization that dramatically sped up comparisons of discriminated unions. Unfortunately, the cost of determining whether a union is discriminated can be prohibitively high. In particular, an internal team with a very large repo saw their type count double and their memory usage increase from 6GB to 9GB, breaking their build. This changes splits the difference by not trying to compute the property types of intersection types - a notoriously slow operation.
Fixes #