-
Notifications
You must be signed in to change notification settings - Fork 175
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
Add Writeable::write_cmp_bytes and use it in DataLocale and Locale #4402
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clever
if self.result != Ordering::Equal { | ||
return Ok(()); | ||
} | ||
let cmp_len = core::cmp::min(other.len(), self.string.len()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if other is longer than self we should be capping out, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If other
is longer, then the only effect is that on the line below the remainder becomes empty and we compare the whole of other
to the whole of self.string
.
The slowdown on locale strict_cmp is reproducable and seems real to me. I traced it down to icu4x/components/locid/src/extensions/mod.rs Lines 266 to 271 in aadc9be
other is empty, but this closure affects perf of that test by 10%.
I was able to inject I haven't looked into asm, so not sure what causes that. |
Thanks @zbraniecki for the investigation. Are you okay merging this with the known 5% impact on |
Yes. I'm mildly curious as to why is it regressing, but I'm comfortable with this tradeoff. |
I realized today that we can do the allocation-free comparisons much more easily than we had been. This new comparison impl is easier to reason about, less code, and faster.
(not sure about the Locale comparison bench; since it makes the others faster, I'm inclined to ignore that or eat the 5%)