Skip to content
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

Merged
merged 1 commit into from
Aug 25, 2017

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Aug 22, 2017

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 divs.

@rust-highfive
Copy link
Collaborator

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@eddyb
Copy link
Member Author

eddyb commented Aug 22, 2017

@bors p=7 This PR should be tested outside of a rollup for perf.rust-lang.org.

@eddyb eddyb force-pushed the apfloat-faster-div branch from 757a146 to b9c69ec Compare August 22, 2017 23:57
@aidanhs aidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 23, 2017
@eddyb
Copy link
Member Author

eddyb commented Aug 24, 2017

@alexcrichton Do you want to review this? It think @arielb1 is unavailable for a few days.
Also, any ideas what made the Travis status get stuck? If you look at Travis itself, it's green.

@alexcrichton
Copy link
Member

I could give this a rubber stamp but unfortunately I don't think I'm equipped to give this an actual review

@eddyb
Copy link
Member Author

eddyb commented Aug 24, 2017

Hmm. Maybe @est31 or @nagisa could help here?

@nagisa
Copy link
Member

nagisa commented Aug 24, 2017

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned arielb1 Aug 24, 2017
/// 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 {
Copy link
Member

@nagisa nagisa Aug 24, 2017

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)?

Copy link
Member Author

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.

@nagisa
Copy link
Member

nagisa commented Aug 24, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Aug 24, 2017

📌 Commit b9c69ec has been approved by nagisa

@eddyb
Copy link
Member Author

eddyb commented Aug 24, 2017

Oh wow the "rollup" in my previous message confused bors...
...
...
@bors p=7

@eddyb
Copy link
Member Author

eddyb commented Aug 24, 2017

@bors rollup-

@bors
Copy link
Contributor

bors commented Aug 24, 2017

⌛ Testing commit b9c69ec with merge c0771f2...

bors added a commit that referenced this pull request Aug 24, 2017
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.
@bors
Copy link
Contributor

bors commented Aug 25, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nagisa
Pushing c0771f2 to master...

@bors bors merged commit b9c69ec into rust-lang:master Aug 25, 2017
@eddyb eddyb deleted the apfloat-faster-div branch August 25, 2017 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants