debris / tiny-keccak

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

1.4.1 is adding 20kb to wasm binaries size #28

Closed NikVolf closed 6 years ago

NikVolf commented 6 years ago

compared to 1.4.0

NikVolf commented 6 years ago

probably due to this:

https://github.com/debris/tiny-keccak/pull/22/files#diff-b4aea3e418ccdb71239b96952d9cddb6R72

@Vurich :)

newpavlov commented 6 years ago

Take a look at sha3 crate, it does not unroll outermost loop, which significantly reduces binary size and even improves performance a bit.

UPD: also by enabling no_unroll feature on keccak crate you'll get even smaller binary size at the expense of some performance loss.

eira-fransham commented 6 years ago

Thanks for tagging me in this. I meant to do this a while ago (the author of sha3 put in a PR to link to their code so I had a look at it and noticed that they'd rerolled the outer loop) but then just, um, didn't. On it now.

eira-fransham commented 6 years ago

Another thing that makes explicit loop unrolling a bit of a deal with the devil is that LLVM doesn't seem to autovectorise unrolled loop code, only "real" loops. LLVM's autovectorisation isn't perfect but until we get simd on stable it's the best we have.

debris commented 6 years ago

fixed in #30