[BigString] Harvest some low-hanging performance fruit #486
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.




This builds on (and temporarily includes the commits of) #485, adds some basic benchmarks, and uses those to make and verify a single set of performance improvements by making use of the known character/scalar/UTF-16 counts to speed up intra-chunk distance calculations.
This makes a roughly 40-50% improvement for distance measurements over
BigString’s character and Unicode Scalar views. Interestingly, we don’t see an improvement for UTF-16 views — I’m guessing this is due to String’s breadcrumbing. (And it will go away with the upcoming UTF8Spanification of this type.)(The benchmarks I added only show an improvement for multi-chunk big string instances, but this is merely an artifact of the specific algorithm that is being measured — for single-chunk strings, the old measurement method was already optimal on that payload, so the new heuristic never triggers.)
rdar://153701624
Checklist