Repository navigation
Conversation
The stitched AES-NI seal is bound by instruction count on the AMD bench (about 277 instructions per 128 bytes), and every counter block cost five of them: an addition, a byte swap, a move to a vector, a shift and the XOR of round key 0. Within a run whose counter low byte, the block's byte 15, does not carry, block j is block 0 plus j by a vector byte addition; the shipped code is three instructions a block (a copy, the addition and the key XOR) and one block build per run. A run that would carry takes the per-block construction; the test reads only the public counter. The seal, CTR and short paths all take it; the VAES-512 path builds its own. A unit test holds the runs to the per-block construction from every low byte, for 8- and 15-block runs and three high counters, including the runs that end exactly at byte 15's carry. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PXEk8BBMDT8tXu4AnENB9Q
Collaborator
Author
|
Closing without landing. On the AMD bench, where this path runs, G3's counter construction made no measurable difference against main's AES-NI code on the same day. Every GCM row was within its 0.3–2.0% spread (https://github.com/ToyOSOrg/evidence/tree/81880a889faf9e0db0409f7984d3338fa6375b0f/pr-1018/r1/metal). On the T14, GCM above 224 B runs on VAES-512, which this PR doesn't touch. Fewer instructions per batch don't move the stitched loop on Zen 2, so the next GCM work (G2/G4 and the round-key-0 reload) starts from main's code. If that work changes the counter construction, the pinning unit test can come with it. |
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 free
to 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.
Based on main 18a3873. One commit, ffd3be5.
Problem
AES-GCM bulk on the AMD bench (AES-NI) is 1.03–1.16x ring. The track records the stitched seal as instruction-bound, at about 277 instructions per 128 B. Each counter block cost five instructions in the shipped code:
lea(the addition),bswap,movd,pslldqand thepxorof round key 0.What changes
This is the analysis's G3.
movdqa,paddbwith a constant,pxor.Checks
All at ffd3be5. Logs: https://github.com/ToyOSOrg/evidence/tree/fdba4666aa7be286eb9a2c6a202979e551dba9c8/pr-1018/r1
cargo run -- --ci host: exit 0, 93 green.-D warnings) in the three forms for the host and--target x86_64-apple-darwin, and forx86_64-unknown-uefi: exit 0.cargo test -p toyos-crypto --features std,sign,wpa2,rustls-provider --release --target x86_64-apple-darwinexits 0. Rosetta admits AES-NI and PCLMULQDQ, so this runs the changed paths. The AEAD differential's 4 KiB and 16 KiB cases reach runs that carry at low byte 250, so both the byte-addition path and the per-block path run against ring and RustCrypto.counter_runs_match_the_per_block_construction: every low byte, 8- and 15-block runs, three high counters.gcm::tests::counters_continue_across_the_stitched_and_tail_pathsand the provider's interop tests.crypto_instrument_prints_its_table(QEMU x86_64): exit 0.Measurements
Readback staged at ffd3be5 (
crypto_instrument,cryptocase; exit 2 = Staged). The rows to read are AES-GCM 1 KiB and 16 KiB, seal and open, on the AMD bench. The T14 takes VAES-512 above 224 B, so there only its one-batch short path changes.Metal
crypto_instrumentpassed at ffd3be5 on both benches (orchestrator's report).Every difference is within the rows' spread (0.3–2.0%). About 8–10 fewer instructions per 128-byte batch did not move the stitched loop. So instruction count alone is not what bounds it on Zen 2, or the new path's round-key-0 reload from the stack costs what the counters saved. This PR should not land on its present evidence; its remaining value is the test, which pins the counter construction.
Not in this PR
🤖 Generated with Claude Code
https://claude.ai/code/session_01PXEk8BBMDT8tXu4AnENB9Q