Closed xaionaro closed 4 years ago
Thanks for the PR! I was surprised to see such an improvement, since newHasher
isn't doing much work. I suppose it can make a difference for very small inputs, though.
I tried out a few approaches to removing the overhead. Here's what I came up with: https://github.com/lukechampine/blake3/commit/617550f0731f2f5d11175ca09e4dca00570cc7fc
The performance is on-par with using sync.Pool
, but the implementation is simpler. I gave you co-author credit on the commit because you inspired me to look for this optimization. :)
Thank you!
To reduce
Hasher
initialization cost in Sum256 and Sum512 it was used a pool to store*Hasher
instances.Result: