-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[String] Fix corner case in comparison fast-path. #20937
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
Conversation
When in a post-binary-prefix-scan fast-path, we need to make sure we are comparing a full-segment scalar, otherwise we miss situations where a combining end-of-segment scalar would be reordered with a prior combining scalar in the same segment under normalization in one string but not the other. This was hidden by the fact that many combining scalars are not NFC_QC=maybe, but those which are not present in any precomposed form have NFC_QC=yes. Added tests.
This regresses performance of some code that hits this fast-path, but I have improvements coming soon that compensates for this fact. |
@swift-ci please benchmark |
@swift-ci please test |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
When in a post-binary-prefix-scan fast-path, we need to make sure we are comparing a full-segment scalar, otherwise we miss situations where a combining end-of-segment scalar would be reordered with a prior combining scalar in the same segment under normalization in one string but not the other. This was hidden by the fact that many combining scalars are not NFC_QC=maybe, but those which are not present in any precomposed form have NFC_QC=yes. Added tests.
* [String] Fix corner case in comparison fast-path. (#20937) When in a post-binary-prefix-scan fast-path, we need to make sure we are comparing a full-segment scalar, otherwise we miss situations where a combining end-of-segment scalar would be reordered with a prior combining scalar in the same segment under normalization in one string but not the other. This was hidden by the fact that many combining scalars are not NFC_QC=maybe, but those which are not present in any precomposed form have NFC_QC=yes. Added tests. * [String] Normalization-boundary-before UTF-8 fast path. All latiny (<0x300) scalars have normalization boundaries before them, so when asking if memory containing a scalar encoded in valid UTF-8 has a boundary before it, check if the leading byte definitely encodes a scalar less than 0x300. * [String] Refactor and fast-path normalization Refactor some normalization queries into StringNormalization.swift, and add more latiny (<0x300) fast-paths. * [String] Speed up constant factors on comparison. Include some tuning and tweaking to reduce the constant factors involved in string comparison. This yields considerable improvement on our micro-benchmarks, and allows us to make less inlinable code and have a smaller ABI surface area. Adds more extensive testing of corner cases in our existing fast-paths. * [String] Hand-increment loop variable for perf. Hand-incrementing the loop variable allows us to skip overflow detection, and will permit more vectorization improvements in the future. For now, it gives us perf improvements in nano-benchmarks.
When in a post-binary-prefix-scan fast-path, we need to make sure we
are comparing a full-segment scalar, otherwise we miss situations
where a combining end-of-segment scalar would be reordered with a
prior combining scalar in the same segment under normalization in one
string but not the other.
This was hidden by the fact that many combining scalars are
NFC_QC=maybe, but those which are not present in any precomposed form
have NFC_QC=yes. Added tests.