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

uint: faster div #126

Merged
merged 23 commits into from
May 8, 2019
Merged

uint: faster div #126

merged 23 commits into from
May 8, 2019

Conversation

ordian
Copy link
Member

@ordian ordian commented Apr 22, 2019

on top of #125 (commits since 8d0e7cd only)
changes:

  • introduces div_mod method
  • adds fuzz tests for div_mod (comparison with gmp) and div_mod_word (u128 / u64, u128 % u64)
  • switches div and mod to div_mod
  • improves perf of div/mod in the worst (for the previous algorithm) case (16x)

By using division algorithm from TAOCP by Knuth, we're now almost as fast as GMP in the worst case 🎉
(GMP is still faster when the divisor is small, but that's not the worst case anymore)
bench results

Note, that performance of div/rem has regressed in some cases.

uint/src/uint.rs Outdated Show resolved Hide resolved
@ordian ordian marked this pull request as ready for review April 24, 2019 13:16
@ordian ordian force-pushed the ao-then-get-ready-for-the-fast-div branch from 7483568 to 1cba3d2 Compare April 25, 2019 13:35
@ordian ordian force-pushed the ao-then-get-ready-for-the-fast-div branch from 1cba3d2 to cb3794d Compare May 4, 2019 12:56
@ordian ordian force-pushed the ao-then-get-ready-for-the-fast-div branch from cb3794d to e81af20 Compare May 4, 2019 13:03
@ordian ordian requested review from sorpaas and tomusdrw May 4, 2019 13:41
@ordian ordian mentioned this pull request May 7, 2019
* master:
  uint: faster mul by u64 (#125)
  fix rocksdb block cache size (#122)
  uint: convert benchmarks to criterion  (#123)
  Bump fixed-hash to 0.3.2 (#134)
  Use EntropyRng instead of OsRng (#130)
  Bump parity-crypto to 0.3.1 (#132)
  rust-crypto dependency removal (#85)
  Use newly stablized TryFrom trait for primitive-types (#127)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants