Skip to content

Settle AArch64's SVE2 ChaCha20 loops by what precedes them - #6993

Merged
alex merged 1 commit into
mainfrom
claude/a64-chacha-sve2-loop
Dec 3, 2026
Merged

alex merged 1 commit into
mainfrom
claude/a64-chacha-sve2-loop

Conversation

@alex

@alex alex commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

ChaCha20's two SVE2 round loops take up to 2.5% longer on Neoverse N2 depending on where their heads are and on the instructions just before them: one nop before the loop of the code from before #6887 also costs 2.2%. #6887 moved them, and its benchmarks did not cover SVE2 (its "default" run passed the literal default to VG_CPU_FEATURES, which turns every feature off).

Mixed8.lead aligns each loop and loads its counter three more times first, which was the best for ChaCha20 at every size of the 30 or so variants measured. Only vg_chacha20_keystream8_sve2 changes.

Code size

Function (bytes) Before After Change
Whole AArch64 crate 1,781,120 1,781,120 0

Benchmarks (Neoverse N2, default features, 20 rounds)

ChaCha20, bytes Against main (run) Against 3638b90, before #6887 (run)
5 0.0% +0.7%
16 0.0% +0.9%
64 0.0% +0.9%
128 0.0% +0.1%
480 0.0% +0.1%
1024 -2.2% -1.0%
1025 -0.5% -1.1%
4097 -1.6% -0.7%
16384 -1.7% +1.0%
ChaCha20-Poly1305 against main (run) Rows Fastest Slowest Rows over 1% slower
chacha20poly1305 18 -0.7% +1.2% 768 bytes (669 → 677 ns)
chacha20poly1305-decrypt 18 -0.1% +0.8% none

The 768-byte row gives back what #6887 had gained there (-0.7%), so against the code from before #6887 it is about +0.5%.

https://claude.ai/code/session_01TKUFHHqqJqUasi9thfRu12


Generated by Claude Code

Their speed depends on where their heads are and on the instructions just
before: since they became a function (#6887), 16 KiB took 2.5% longer on
Neoverse N2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHqqJqUasi9thfRu12
@github-actions github-actions Bot added the untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified. label Dec 3, 2026
@alex
alex marked this pull request as ready for review December 3, 2026 04:05
@alex
alex added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit e522dff Dec 3, 2026
32 checks passed
@alex
alex deleted the claude/a64-chacha-sve2-loop branch December 3, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified.

Development

Successfully merging this pull request may close these issues.

2 participants