Uh oh!
There was an error while loading. Please reload this page.
keccak: avoid materializing round constants array - #128
Closed
shuklaayush wants to merge 1 commit into
Closed
Conversation
newpavlov
commented
Aug 19, 2026
Member
With enabled optimization this code gets optimized into a pre-computed const table, so this change is not necessary. |
shuklaayush
commented
Aug 19, 2026
Author
@newpavlov thanks for the reply! the conversions are constant-folded into a table, but the owned array is still materialized in the optimized aarch64 codegen before: subsp,sp, #0x190ldp q0, q1,[x8, #0x80]stp q0, q1,[sp, #0xf0]ldp q0, q1,[x8, #0xa0]stp q0, q1,[sp, #0x110]ldp q0, q1,[x8, #0x40]stp q0, q1,[sp, #0xb0]ldp q0, q1,[x8, #0x60]stp q0, q1,[sp, #0xd0]ldp q0, q1,[x8]stp q0, q1,[sp, #0x70]ldp q0, q1,[x8, #0x20]stp q0, q1,[sp, #0x90]after: subsp,sp, #0xc0adrp x9, ...add x9, x9, ...ldr x9,[x9, x8]on my macbook air m3, running RUSTFLAGS='--cfg keccak_backend="soft"' \
cargo +nightly bench -p keccak --bench mod -- keccak_f1600 --exactgoes from 172.63 ns before to 145.93 ns after |
newpavlov
commented
Aug 19, 2026
Member
Interesting. I opened #129 to resolve it in a different and hopefully less fragile fashion. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.map()to lazy iterator mapping for round constants[L; ROUNDS], reducing stack usage