Skip to content

keccakf_arm64: drop unused 200-byte frame, mark NOSPLIT - #12

Open
AskAlexSharov wants to merge 3 commits into
masterfrom
perf/arm64-nosplit-frame
Open

keccakf_arm64: drop unused 200-byte frame, mark NOSPLIT#12
AskAlexSharov wants to merge 3 commits into
masterfrom
perf/arm64-nosplit-frame

Conversation

@AskAlexSharov

@AskAlexSharov AskAlexSharov commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

The arm64 TEXT directive 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)

                      │  old        │  new                       │
FasterKeccak/32B-16     137.3n ± 5%   128.0n ± 2%  -6.81% (p=0.000 n=8)

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.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 ·keccakF1600Sha3 from a $200-16 frame to NOSPLIT, $0-16 on 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@AskAlexSharov
AskAlexSharov force-pushed the perf/arm64-nosplit-frame branch from 7dffb4d to f792e6b Compare July 20, 2026 08:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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