hashes icon indicating copy to clipboard operation
hashes copied to clipboard

`blake2` code size very high (overuse of`#[inline(always)]`?)

Open thomcc opened this issue 4 years ago • 1 comments

I have ~150kb of code for blake2::blake2b::VarBlake2b::compress under -Copt-level=z, which is around 3x larger than any other function in my binary. It would be nice if it were smaller.

Looking at https://github.com/RustCrypto/hashes/blob/master/blake2/src/blake2.rs, a lot is #[inline(always)], and the round calls are manually unrolled.

There's a good chance these would still get inlined and unrolled on -Copt-level=3 if it were written using #[inline] and a loop, but it would make a big difference to use cases where large code is undesirable.

thomcc avatar Oct 07 '21 07:10 thomcc

Note that there's an open PR to completely replace the current implementation: #228

tarcieri avatar Oct 07 '21 13:10 tarcieri