Skip to content

Optimize compression input copy#240

Merged
TomWambsgans merged 1 commit into
leanEthereum:mainfrom
malik672:optir
May 31, 2026
Merged

Optimize compression input copy#240
TomWambsgans merged 1 commit into
leanEthereum:mainfrom
malik672:optir

Conversation

@malik672
Copy link
Copy Markdown
Contributor

@malik672 malik672 commented May 31, 2026

Summary

  • replace two slice copies with a single flattened contiguous copy in symetric::compress
  • keep the change scoped to crates/backend/symetric/src/compression.rs

IR / asm impact

For the concrete optimized instantiation compress::<KoalaBear, Poseidon1KoalaBear16, 8, 16>:

Old input-copy shape:

  • LLVM IR showed two separate input-side copies: memcpy 32 + memcpy 32
  • AArch64 asm loaded/stored the two halves separately before the compression call

New input-copy shape:

  • LLVM IR shows one contiguous input-side copy: memcpy 64
  • AArch64 asm still lowers that 64-byte copy into two 32-byte vector load/store pairs on this target, but the extra staging buffer in the old helper goes away

Overall optimized function effect:

  • old IR: two 32-byte copies into state, then an extra 64-byte copy into the compression buffer
  • new IR: one 64-byte copy directly into the compression buffer
  • old asm frame size: 224 bytes
  • new asm frame size: 160 bytes

Source change:

state[..2 * CHUNK].copy_from_slice(input.as_flattened());

Validation

  • cargo check -p mt-symetric

@TomWambsgans TomWambsgans merged commit d559dc2 into leanEthereum:main May 31, 2026
3 checks passed
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