Skip to content

Conversation

@dvdplm
Copy link
Contributor

@dvdplm dvdplm commented May 17, 2018

Not unrolling the outer loop seems to speed up hashing quite significally:

Original (unrolled):

running 3 tests
test bench_keccak_256_with_empty_input   ... bench:         557 ns/iter (+/- 46)
test bench_keccak_256_with_large_input   ... bench:      17,288 ns/iter (+/- 1,871) = 236 MB/s
test bench_keccak_256_with_typical_input ... bench:         577 ns/iter (+/- 28) = 88 MB/s

This branch (not unrolled):

running 3 tests
test bench_keccak_256_with_empty_input   ... bench:         487 ns/iter (+/- 25)
test bench_keccak_256_with_large_input   ... bench:      14,645 ns/iter (+/- 675) = 279 MB/s
test bench_keccak_256_with_typical_input ... bench:         495 ns/iter (+/- 32) = 103 MB/s

"Inspired" by https://github.com/RustCrypto/sponges/blob/master/keccak/src/lib.rs#L138

Running benchmarks from the keccak-hash crate so we can compare to the numbers here.

dvdplm added 2 commits May 17, 2018 11:27
Not unrolling the outer loop seems to speed up hashing quite significally:

Original (unrolled):
```
running 3 tests
test bench_keccak_256_with_empty_input   ... bench:         557 ns/iter (+/- 46)
test bench_keccak_256_with_large_input   ... bench:      17,288 ns/iter (+/- 1,871) = 236 MB/s
test bench_keccak_256_with_typical_input ... bench:         577 ns/iter (+/- 28) = 88 MB/s
```

This branch (not unrolled):
```
running 3 tests
test bench_keccak_256_with_empty_input   ... bench:         487 ns/iter (+/- 25)
test bench_keccak_256_with_large_input   ... bench:      14,645 ns/iter (+/- 675) = 279 MB/s
test bench_keccak_256_with_typical_input ... bench:         495 ns/iter (+/- 32) = 103 MB/s
```

"Inspired" by https://github.com/RustCrypto/sponges/blob/master/keccak/src/lib.rs#L138

Running benchmarks from the `keccak-hash` crate so we can compare to the numbers [here](paritytech/keccak-hash#1).
@dvdplm
Copy link
Contributor Author

dvdplm commented May 18, 2018

@debris ptal

@debris
Copy link
Owner

debris commented May 19, 2018

already merged #30 . Please rebase if still relevant :)

* origin:
  Remove hack no longer needed are rerolling loop
  Reroll outer loop
@dvdplm dvdplm changed the title Don't unroll outer loop for speed™ Add a test for overlapping buffers ~~Don't unroll outer loop for speed™~~ May 19, 2018
@dvdplm dvdplm changed the title Add a test for overlapping buffers ~~Don't unroll outer loop for speed™~~ Add a test for overlapping buffers (WAS: Don't unroll outer loop for speed™) May 19, 2018
@dvdplm
Copy link
Contributor Author

dvdplm commented May 19, 2018

Now it's down to adding a test for overlapping buffers. Merge? :)

@debris debris merged commit fabf4e7 into debris:master May 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