-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Speed up APFloat division by using short division for small divisors. #44051
Conversation
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
@bors p=7 This PR should be tested outside of a rollup for perf.rust-lang.org. |
757a146
to
b9c69ec
Compare
@alexcrichton Do you want to review this? It think @arielb1 is unavailable for a few days. |
I could give this a rubber stamp but unfortunately I don't think I'm equipped to give this an actual review |
r? @nagisa |
/// One, not zero, based LSB. That is, returns 0 for a zeroed significand. | ||
pub(super) fn olsb(limbs: &[Limb]) -> usize { | ||
for i in 0..limbs.len() { | ||
if limbs[i] != 0 { |
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.
Why not just iterate the limbs
slice directly (with enumerate
adapter)?
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.
With enumerate
? That's a transformation that can probably be done in a few places but I didn't do it in the original port.
@bors r+ |
📌 Commit b9c69ec has been approved by |
Oh wow the "rollup" in my previous message confused bors... |
@bors rollup- |
Speed up APFloat division by using short division for small divisors. Fixes #43828 (hopefully), by not doing long division bit-by-bit for small divisors. When parsing the ~200,000 decimal float literals in the `tuple-stress` benchmark, this change brings roughly a 5x speed increase (from `0.6s` to `0.12s`), and the hottest instructions are native `div`s.
☀️ Test successful - status-appveyor, status-travis |
Fixes #43828 (hopefully), by not doing long division bit-by-bit for small divisors.
When parsing the ~200,000 decimal float literals in the
tuple-stress
benchmark, this change brings roughly a 5x speed increase (from0.6s
to0.12s
), and the hottest instructions are nativediv
s.