Discussion: switch minio/blake2b-simd to golang.org/x/crypto #44
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.
Intentionally opening as a Draft for discussion, rather than a PR.
This explores a migration away from
minio/blake2b-simd
module for hashing, in favor of thegolang.org/x/crypto
implementation. The minio version appears to have been archived in 2018 and thus no longer receives updates/audits.While the impetus for suggesting this change was code maintenance and supply-chain security rather than performance, the performance characteristics of the standard
golang.org/x/crypto
blake2b hash does appear to now be better optimized for both Intel and ARM intrinsics than the originalminio/blake2b-simd
. I created a benchmark suite to test hashing performance specifically at https://github.com/mroth/blakebench, which on the hardware I had access to appears to perform roughly ~25% better.arm64:
amd64:
Note that for the existing benchmarks in this module, the difference appears to be negligible, since the current implementation (which I did not adjust) initializes a new hash.Hash for every operation, which I suspect likely consumes nontrivial time compared to the actual hashing itself. Before and after comparison on my laptop of
go test -bench=. -count=5 -cpu=1
.Note that looking at the dependency chain, this module does still indirectly import
minio/blake2b-simd
via its dependency on the (now deprecated, it appears)ipfs/go-ipld-cbor
module, so if going this route one may also wish to explore a migration toipfs/go-ipld-prime
which is apparently the stated replacement.