Faster floor_sqrt, checked_sqrt implementation#1312
Open
andrewwhitehead wants to merge 5 commits into
Open
Conversation
…n_vartime Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1312 +/- ##
==========================================
+ Coverage 91.04% 91.22% +0.18%
==========================================
Files 189 190 +1
Lines 22598 22850 +252
==========================================
+ Hits 20574 20846 +272
+ Misses 2024 2004 -20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This re-applies the changes in #1258 with fixes for #1303. Changes to the
BoxedUintproptests in #1310 also help to validate the results.The sqrt logic is implemented on
UintRef, meaning one version is used for bothUintandBoxedUint. This uses algorithm 1.12 in Modern Computer Arithmetic rather than 1.13, which scales better for large integers (approx O(2n)).Addition and subtraction methods in
UintRefare adjusted to accept an rhs smaller than self. This was inconsistently applied before.checked_sqrt(_vartime) no longer performs an additional squaring, so its performance matchesfloor_sqrt.Performance seems to be even better now, maybe due to
bitleninlining or other changes.Sample benchmarks