Skip to content

Mikeo/lowmem bench tweaks v2 - #177

Open
ounsworth wants to merge 23 commits into
bcgit:release/0.1.3alphafrom
ounsworth:mikeo/lowmem_bench_tweaks_v2
Open

ounsworth wants to merge 23 commits into
bcgit:release/0.1.3alphafrom
ounsworth:mikeo/lowmem_bench_tweaks_v2

Conversation

@ounsworth

@ounsworth ounsworth commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

This is a rebasing replacement of #136

In short, I had Claude do a review for silent copies in the mlkem and mldsa lowmemory crates and it found a couple of instance of:

  • moves that were being compiled as a pass-by-value copy
  • .try_into() that created a copy as a result of needing an intermediate owned copy.
    And similar patterns.
  • Adjusted the size of the SHAKE pre-buffer in SampleNTT() / RejNTTPoly() to match exactly a SHAKE block size boundary.

The net result is about a 2 - 4 kb reduction across the whole lowmemory suite, and also some tightening up in the non-optimized implementation.

Also, importantly, this PR preserves the lessons-learned in a new Claude skill `memory-hygiene-in-rust so that it's easier to audit future code for the same hidden memcpy's.

ounsworth and others added 23 commits October 24, 2026 10:10
…eing held in a Polynomial [i32; 256], it's now bit-packed into a [u8; 32].
…LVM lays out stack frames and give slightly better numbers
…pansion so that it doesn't get sucked into the caller's stack frame.
…skill

The Architecture paragraph introducing memory hygiene already names the
skill; the stand-alone sentence under Stack Usage Benchmarks repeated it.
Also "cast" -> "cost" in that paragraph.

Assisted-by: Claude:claude-fable-5-1
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ounsworth ounsworth added this to the 0.1.3alpha milestone Oct 24, 2026

fn A_hat(&self) -> P::MatrixA {
self.sk.A_hat()
self.A_hat.clone()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Merge this PR after #179, and see if we can turn this into a lifetime'd borrow instead of a clone.

@ounsworth
ounsworth marked this pull request as ready for review October 25, 2026 16:20
@ounsworth
ounsworth requested review from jjkurczak and mwcw October 27, 2026 12:12

This branch has not been deployed

No deployments
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.

1 participant