keccakf_arm64: drop unused 200-byte frame, mark NOSPLIT - #12
Open
AskAlexSharov wants to merge 3 commits into
Open
keccakf_arm64: drop unused 200-byte frame, mark NOSPLIT#12AskAlexSharov wants to merge 3 commits into
AskAlexSharov wants to merge 3 commits into
Conversation
The TEXT directive declared a 200-byte stack frame that the function never touches — the whole state lives in V registers. The frame forces a stack-bound check and frame setup/teardown on every permutation call (once per 136-byte block). Declare NOSPLIT $0-16 instead. ~7% faster on single-block hashes on an Apple M-series (BenchmarkFasterKeccak/32B: 137.3ns -> 128.0ns, p=0.000, n=8); larger sizes within noise.
There was a problem hiding this comment.
Pull request overview
This PR optimizes the arm64 Keccak-f[1600] permutation assembly by removing an unused stack frame and marking the function as NOSPLIT, reducing per-call overhead in the hot permutation path.
Changes:
- Change
TEXT ·keccakF1600Sha3from a$200-16frame toNOSPLIT, $0-16on arm64. - Eliminate the implicit stack growth check and prologue/epilogue associated with a non-zero frame.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AskAlexSharov
force-pushed
the
perf/arm64-nosplit-frame
branch
from
July 20, 2026 08:16
7dffb4d to
f792e6b
Compare
…frame # Conflicts: # keccakf_arm64.s
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.
The arm64
TEXTdirective declared a 200-byte stack frame that the function never uses — the entire Keccak state lives in V0–V24 and never spills. A non-NOSPLIT frame costs a stack-bound check plus frame setup/teardown on every permutation call, i.e. once per 136-byte block (this is likely a leftover from an earlier version that spilled state to the stack).Change to
NOSPLIT, $0-16.Benchmark (Apple M-series, arm64)
Larger sizes trend faster but were within noise on my machine (background load). The win is concentrated on short inputs where per-call overhead matters most — the hot case for trie/state-key hashing.
go test ./...,go vet, and a fuzz run vs x/crypto all pass with the change.