debris / tiny-keccak

An implementation of Keccak derived functions specified in FIPS-202, SP800-185 and KangarooTwelve
Creative Commons Zero v1.0 Universal
194 stars 50 forks source link

Fix borrows #8

Closed burdges closed 7 years ago

burdges commented 7 years ago

Incidentally this improve performance slightly because the compiler avoids some check caused by the extra unsafe code:

Old : test bench_sha3_256_input_4096_bytes ... bench: 19,252 ns/iter (+/- 2,023) = 212 MB/s test keccakf_u64 ... bench: 591 ns/iter (+/- 234) = 42 MB/s

New: test bench_sha3_256_input_4096_bytes ... bench: 18,195 ns/iter (+/- 851) = 225 MB/s test keccakf_u64 ... bench: 574 ns/iter (+/- 19) = 43 MB/s

debris commented 7 years ago

I'm not sure about that... on my machine I see no difference. Have you compared generated assembly?

burdges commented 7 years ago

It likely depends upon your rust version, but one should broadly expect unsafe code to grow slower in future as the memory model work proceeds.

burdges commented 7 years ago

I've pushed an update to this branch for the current master and partially addressed #9

burdges commented 7 years ago

Oh https://github.com/debris/tiny-keccak/pull/11 is probably better.

burdges commented 7 years ago

Now closing since https://github.com/debris/tiny-keccak/pull/11 is merged.