-
Notifications
You must be signed in to change notification settings - Fork 268
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
all: use SHA256 with SIMD instructions for higher performance and throughout #700
Comments
Is it okay to assign this to you and your team @odeke-em |
Yes, please @marbar3778! We are working on it. I just need to find a machine with AVX512 so that we can produce benchmarks. |
In support of using that library! Though I think its probably advisable to turn off AVX 512 via build flag, given the SDK workload (https://lemire.me/blog/2018/09/07/avx-512-when-and-how-to-use-these-new-instructions/) |
+1 |
Also of interest for this issue are a number of occurrences of These come from what appears to be a helper function that wraps crypto/sha256: We'd probably want to either replace these usages or update cometbft to use the SIMD library as well. |
thanks for the insight, i would advocate for replacing the wrapped function as we are trying to rely less on comet |
The last time I check it, I don't see much improvements on dev machines I got at hand (x86_64 mac laptop and arm64 linux), on mac the stdlib is actually much faster, I just rerun the benchmark with go1.20 and post the result as follows: arm64 linux
amd64 mac
|
@yihuang I did some digging and it looks like the Go standard library has support for ARM SHA extensions and AVX2, which could explain why sha256-simd advertises improved performance for processors with Intel SHA Extensions or AVX512, which the standard library doesn't have optimizations for. I didn't see any improvements for cosmos-sdk benchmarks with the simd library on my workstation, which has Intel SHA Extensions (5950x), but I plan to also benchmark on a machine with AVX512. |
actually iavl library use sha256 heavily, should have bigger impact there. |
I ran benchmarks for cosmos-sdk and iavl on machines with AVX512 and Intel SHA Extensions with and without using the SIMD library, and got these results: https://gist.github.com/kirbyquerby/6635113b003abdaeaa93618d4e6970a2 There didn't seem to be significant improvements (in many benchmarks, there's even a slowdown) for using the SIMD library in either cosmos-sdk or iavl. |
would be interesting to test this in iavl https://github.com/prysmaticlabs/gohashtree. see if there is any change |
I can reproduce the intel benchmark result on my mac laptop, it's faster by 6x if you do at least 16 hashing operations in a batch.
|
Shall we close this issue, and open new in IAVL if we want to dig more gohashtree usage there? |
ill transfer this issue there.
we can either modify our code or have a variation of their code |
In this repository, we heavily use the Go standard library's crypto/sha256. However there exists a Single Instruction Multiple Data (SIMD) package from our friends at Minio per https://github.com/minio/sha256-simd and it promises 8X speed ups when using AVX instructions. We should explore this.
Let's explore if performance radically improves and then plumb it in.
Kindly cc-ing my colleague @elias-orijtech
For Admin Use
The text was updated successfully, but these errors were encountered: