Gopher Robot submitted the change![Open in Gerrit]()
Change information
Commit message:
runtime, cmd/compile: use preemptible memclr for large pointer-free clears
Large memory clearing operations (via clear() or large slice allocation)
currently use non-preemptible assembly loops. This blocks the Garbage
Collector from performing a Stop The World (STW) event, leading to
significant tail latency or even indefinite hangs in tight loops.
This change introduces memclrNoHeapPointersPreemptible, which chunks
clears into 256KB blocks with preemption checks. The compiler's walk
phase is updated to emit this call for large pointer-free clears.
To prevent regressions, SSA rewrite rules are added to ensure that
constant-size clears (which are common and small) continue to be
inlined into OpZero assembly.
Benchmarks on darwin/arm64:
- STW with 50MB clear: Improved from 'Hung' to ~500µs max pause.
- Small clears (5-64B): No measurable regression.
- Large clears (1M-64M): No measurable regression.
Fixes #69327
Change-Id: Ide14d6bcdca1f60d6ac95443acb57da9a8822538
Files:
- M src/cmd/compile/internal/ssa/_gen/generic.rules
- M src/cmd/compile/internal/ssa/rewritegeneric.go
- M src/cmd/compile/internal/typecheck/_builtin/runtime.go
- M src/cmd/compile/internal/typecheck/builtin.go
- M src/cmd/compile/internal/walk/assign.go
- M src/cmd/compile/internal/walk/range.go
- M src/runtime/malloc.go
- M src/runtime/memmove_test.go
Change size: M
Delta: 8 files changed, 47 insertions(+), 9 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +1 by Robert Griesemer, +2 by Keith Randall, +1 by Keith Randall
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ide14d6bcdca1f60d6ac95443acb57da9a8822538
Gerrit-Change-Number: 750480
Gerrit-PatchSet: 3