Repository navigation
keccak: test that the permutation kernel stays preemptible - #33
Closed
AskAlexSharov wants to merge 2 commits into
Closed
AskAlexSharov wants to merge 2 commits into
AskAlexSharov wants to merge 2 commits into
Conversation
#32 removed NOSPLIT from the amd64 kernel so the runtime regains a preemption point in the absorb and squeeze loops. Nothing stops it coming back, and the failure is invisible in throughput benchmarks: it only shows up as a stop-the-world pause in whatever else the process is doing. TestKernelKeepsStackCheck reads the TEXT directives and rejects both ways of losing the stack-growth check: NOSPLIT, and a frame under 128 bytes, which makes the assembler mark a leaf NOSPLIT on its own. It covers both architectures from any runner, so an arm64 CI job still catches an amd64 regression. TestSTWPauseWhileHashing measures the property itself from the runtime's /sched/pauses/stopping/gc:seconds histogram. Its budget is relative: it hashes the same buffer through the pure-Go fallback first, which always has a preemption point, and only fails if the assembly path stalls the world four times longer than that and past 5ms. A slow or loaded runner moves both numbers together; only a real regression separates them. Verified by putting NOSPLIT back, assembly against the pure-Go floor: amd64 (EPYC 4344P) 20.48 us -> 83.886 ms arm64 (M4 Max) 327.68 us -> 100.663 ms, floor 163.84 us
AskAlexSharov
force-pushed
the
test/asm-preemption
branch
from
August 16, 2026 06:50
20503fc to
7ebf06f
Compare
…togram The stopping-pause histogram is cumulative for the life of the process, so picking its highest non-empty bucket attributes any earlier pause -- another test, the warm-up -- to the code under test. Taking bucket deltas fixes that but needs a sleep afterwards so a blocked stop-the-world is recorded before the snapshot, which is easy to get wrong. Timing runtime.GC() from another goroutine measures the same thing without a histogram, and the budget is already relative to the pure-Go fallback, so the extra precision was not buying anything. Verified both ways on both architectures. Healthy: 327us assembly against 668us pure Go on M4 Max, 416us against 526us on EPYC 4344P. With NOSPLIT put back: 91.9ms against 1.1ms, and 73.8ms against 596us. Matches the same test in erigon and klauspost/compress.
AskAlexSharov
force-pushed
the
test/asm-preemption
branch
from
August 16, 2026 12:29
4592708 to
8fce91b
Compare
Contributor
Author
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.
#32 removed
NOSPLITfrom the amd64 kernel so the runtime regains a preemption point in the absorb and squeeze loops. Nothing stops it coming back, and the failure is invisible in throughput benchmarks — it only shows up as a stop-the-world pause in whatever else the process is doing.TestKernelKeepsStackCheck
Reads the
TEXTdirectives and rejects both ways of losing the check:NOSPLIT, which drops it whatever the frame size;NOSPLITon its own (abi.StackSmall, arm64).The second one is the trap: deleting the keyword alone changes nothing if the frame is small, which is why #12 would have reintroduced the stall on arm64. The test reads both
.sfiles regardless of the runner's architecture, so an arm64 CI job still catches an amd64 regression.TestSTWPauseWhileHashing
Measures the property the directives only imply, using the runtime's own
/sched/pauses/stopping/gc:secondshistogram while hashing 64 MiB with GC pressure on another goroutine. It reads the histogram delta rather than the process-lifetime max, and waits before reading so a blocked stop-the-world is recorded first.Verification
Both tests pass on master. Putting
NOSPLITback on the kernel of each architecture:NOSPLITrestoredThe budget is 5 ms — two orders of magnitude away from both the healthy and the broken value, so there is nothing to tune. The test takes 1.3 s and skips under
-short, whenGOMAXPROCS < 2, and when the CPU has no assembly backend (the pure-Go path is preemptible, so there is nothing to measure).