-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Auto-detect SHA256 implementation in benchmarks #19214
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
Conversation
comparing this to current master this seems to actually be slower (if only very slightly), running debian 10.4 on an i7-8550U
|
tested ACK addf18d For me, the SHA256 tests are speeding up significantly after this. |
I must have gotten something wrong, doing the benchmarks again after git clean shows this pr being about 6x faster ACK addf18d |
Can hashing be made to fail when |
On a 2019 Macbook Pro: src/bench/bench_bitcoin -filter=SHA256.* Before:
After (addf18d):
|
Maybe it would be useful to specify here what SHA256 implementation is benchmarked. This makes comparisons slightly more meaningful. |
From IRC:
If another benchmark spins up a testing setup, that testing setup will call auto detect. So this explains the confusing results where the naive implementation is faster than avx2. |
There should probably be a way to force a specific implementation? (I think always defaulting to the generic implementation makes sense...) |
In the functional tests we use if self.is_foobar_compiled():
self.test_foobar() Something along those lines could also be used to bench the different hash impls. here. |
Yes, benchmarking all the different SHA356 implementations could be useful as well. I think this was the case in one of the initial PRs that introduced more of them. That said that still leaves open what to do for other benchmarks that might depend on the SHA256 implementation. We don't want to re-run all the benchmarks for all the supported implementations ofc. |
I generally don't like using globals to magically change control flow, especially in tests. There have been enough cases in the past where global state in tests has lead to confusing results. (Including this very benchmark: #19214 (comment)) Which is why I suggested to force a decision before hashing is used: #19214 (comment) The silent fallback shouldn't be needed, or am I missing something obvious? |
I think there's something of an initialization order issue here. Some of the objects initialized before |
ACK addf18d |
addf18d Call SHA256AutoDetect in benchmark setup (Pieter Wuille) Pull request description: It seems `SHA256AutoDetect()` was not being called in benchmarks, making the numbers only reflect the naive implementation. Fix this by calling it in bench_bitcoin's setup. ACKs for top commit: fjahr: tested ACK addf18d pstratem: ACK addf18d laanwj: ACK addf18d Tree-SHA512: 3ba4b068145942df1429bf5913e3f685511e6ebeae2c1a3f9b8ac0144f6db1c7df456f88f480a2129f3e1602e3bf6a39530bb96e2c74c03ddb19324cec6799c7
Summary: > It seems SHA256AutoDetect() was not being called in benchmarks, making the numbers only reflect the naive implementation. Fix this by calling it in bench_bitcoin's setup. This is a backport of [[bitcoin/bitcoin#19214 | core#19214]] Test Plan: `ninja bench-bitcoin` I don't see a significant difference in the SHA256 becnhmarks before or after this commit. Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D10004
It seems
SHA256AutoDetect()
was not being called in benchmarks, making the numbers only reflect the naive implementation. Fix this by calling it in bench_bitcoin's setup.