Skip to content
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

reduce allocs by using optimized single use Keccak256/512 Hash #59

Merged
merged 1 commit into from
Mar 11, 2018

Conversation

jmank88
Copy link
Contributor

@jmank88 jmank88 commented Mar 11, 2018

This PR aims to speed up and reduce garbage, and allocations in general, from hashing. The main change is optimized forms of Keccak256/512 for one-time usages. Some additional tweaks were made at call sites as well to reduce copying and allocations. These new benchmarks illustrate the difference:

BenchmarkKeccak256/unoptimized-4         	 2000000	       921 ns/op	     960 B/op	       4 allocs/op
BenchmarkKeccak256/optimized-4           	 2000000	       729 ns/op	     448 B/op	       1 allocs/op
BenchmarkKeccak512/unoptimized-4         	 2000000	       884 ns/op	    1024 B/op	       4 allocs/op
BenchmarkKeccak512/optimized-4           	 2000000	       691 ns/op	     512 B/op	       2 allocs/op

@jmank88 jmank88 requested a review from treeder March 11, 2018 19:21
@treeder treeder merged commit 9de9516 into master Mar 11, 2018
@treeder treeder deleted the sha branch March 11, 2018 19:27
@jmank88 jmank88 mentioned this pull request Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants