-
Notifications
You must be signed in to change notification settings - Fork 974
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
Fix Jacobi benchmarks and other benchmark improvements #797
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.
ACK mod nit
Isn't it more meaningful to test it with p as the prime of the jacobi symbol? (tested locally and the result are very similiar, but I think that for purposes like schnorr this is what we care about) EDIT: I see that |
FYI this seem to be slightly slower than the actual random average. before this PR I got: (locked on 2.4Ghz)
with this PR:
with randomly chosen inputs for
(code diff for this https://pastebin.com/raw/ewuiYxGc) |
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.
ACK. I had assumed the different results with the precomputed values were probably largely alignment/cache/branch predictor issues. There has been some academic work to eliminate these effects by basically making a bunch of different binaries with the memory layout all randomized and benchmarking all of them. ... but unfortunately, like a billion other computer science research things that have shipped modified versions of clang, I wasn't able to get their code to work with the effort I was willing to put in. I've contemplated before making benchmarks use precomputed values but it's also really nice if the benchmarks can run on low memory systems with minimal modification. Costs like add/etc could be subtracted out. |
With the prospect of not needing Jacobi symbols anymore for BIP340 (and it possibly being removable from the codebase), the third commit may end up not being very useful long term. It doesn't hurt though. I think this is ready. |
@sipa I think my comment above is still unresolved (#797 (comment)) |
The _x and _y suffices are confusing; they don't actually correspond to X and Y coordinates. Instead replace them with arrays.
Also increase the number of fe inputs.
Also make the num_jacobi benchmark use the scalar order as modulus, instead of a random number.
38a7bb3
to
cb5524a
Compare
ACK cb5524a |
1 similar comment
ACK cb5524a |
Summary: * Rename bench_internal variables The _x and _y suffices are confusing; they don't actually correspond to X and Y coordinates. Instead replace them with arrays. * Randomize the Z coordinates in bench_internal Also increase the number of fe inputs. * Make jacobi benchmarks vary inputs Also make the num_jacobi benchmark use the scalar order as modulus, instead of a random number. * Add benchmark for secp256k1_ge_set_gej_var This is a backport of secp256k1 [[bitcoin-core/secp256k1#797 | PR797]] Test Plan: ninja bench-secp256k1 Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D7612
Summary: * Rename bench_internal variables The _x and _y suffices are confusing; they don't actually correspond to X and Y coordinates. Instead replace them with arrays. * Randomize the Z coordinates in bench_internal Also increase the number of fe inputs. * Make jacobi benchmarks vary inputs Also make the num_jacobi benchmark use the scalar order as modulus, instead of a random number. * Add benchmark for secp256k1_ge_set_gej_var This is a backport of secp256k1 [[bitcoin-core/secp256k1#797 | PR797]] Test Plan: ninja bench-secp256k1 Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D7612
A number of improvements to
bench_internal
:gej_to_ge_var
.