Skip to content

Conversation

@Dirbaio
Copy link
Contributor

@Dirbaio Dirbaio commented Dec 9, 2022

The implementation uses some inline(always) to force inline the round and quarter_round functions for performance. This PR adds an opt-in Cargo feature to disable them, to allow optimizing for size instead.

Building for thumbv6m-none-eabi:

  • size_opt disabled: 5772 bytes
  • size_opt enabled: 2372 bytes

This saves 3.4kb of code size, which is 60%.

I'm trying to use blake2 on a microcontroller with 32kb of Flash memory (where the code is stored), so saving 3.4kb is quite substantial.

simd = []
simd_opt = ["simd"]
simd_asm = ["simd_opt"]
size_opt = [] # Optimize for code size. Removes some `inline(always)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a new line here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, done!

@newpavlov
Copy link
Member

Thank you! I will release it shortly.

@newpavlov newpavlov merged commit f8b2eab into RustCrypto:master Dec 16, 2022
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