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

Add a test for overlapping buffers (WAS: Don't unroll outer loop for speed™) #29

Merged
merged 4 commits into from
May 19, 2018

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.

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).
…ont-unroll-outer-loop

* 'master' of https://github.com/debris/tiny-keccak:
  Add test for keccak 256 with some actual content
@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