feat(crypto): Upgrade all usage of crypto/sha256 to minio/sha256-simd#2909
feat(crypto): Upgrade all usage of crypto/sha256 to minio/sha256-simd#2909itsdevbear wants to merge 1 commit intocometbft:mainfrom
crypto/sha256 to minio/sha256-simd#2909Conversation
crypto/sha256 to simd-256crypto/sha256 to minio/sha256-simd
|
Thanks for this @itsdevbear. We will shortly be running large scale tests with (and without) this PR. If we see visible performance gain, we'll adopt this. |
|
Will be CPU architecture dependant, ensure test environment is setup correctly |
crypto/sha256 to minio/sha256-simdcrypto/sha256 to minio/sha256-simd
|
Thanks @itsdevbear. @sergio-mena do you know if we have a mixed environment in our tests ? Do we test on Intel and ARM ? Looks like the benefits are dependent on message size according to the repo. Might be also interesting to see if this could be tested with different input sizes. |
|
One concern that I have though is that this library seems to be a bit stale, last commit was February 2023. Maybe it's stable enough. But since we're replacing it everywhere where a Sha256 is needed, changing it on hash, merkletree, keys, etc, It is critical that this library is vetted. I understand this is used in production in many projects, but the concern is if there's a vulnerability how fast it can be addressed as opposed to using the official one that would be patched possibly faster. |
|
We are in the process of having an expert in golang crypto libraries vet this library change. |
|
I can also hide behind an optional build flag if desired. |
|
@andynog yeah intel and arm, but notably will see the greatest improvement on cpus with AVX-512 support |
|
This being said, we want to optimize some places in the code to use the AVX-512 scheduler directly. But that's a bigger change |
|
This package was added by #2765. Not sure why they decided to use this precise implementation. |
|
Overall the code now is kind of confusing with the use of:
We might consider simplifying this setup. |
|
Personally, I like having everywhere in the codebase important from tmhash where tmhash is an alias it whatever library we like. This alias could be changed via build flags for instance. many to one to few relationship |
Can you add a Go test/benchmark so we can evaluate this boost? |
|
We discussed about this in our internal meeting today. These are the conclusions:
Therefore, we will:
|
Opened #3071. |
IDK how much realworldish gain there is, but:
hehe this would make it a lot faster on my homebrew routers which use the J3455 cpu
That's basically "every validator" Agree with @andynog's concern about maintenance though, that is an easy way to get burned. PR into crypto/sha256? The performance gains are pretty undeniable, and while the SHA extensions are (bizarrely) on just one intel cpu + AMD ryzen, a lot of validators use Ryzen. |
That's the culprit of this PR 😅 |
|
https://twitter.com/phoronix/status/1790016231614849318 What scenario would allow us to see real world results here? |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Closing as per #2909 (comment). |
Free performance boost, used in hundreds of production projects.
PR checklist
.changelog(we use unclog to manage our changelog)docs/orspec/) and code comments