Repository navigation
spin v0.1.2 — low-latency spin primitives for Go
Overview
spin provides small, low-latency spin primitives for performance-critical Go code paths.
Highlights
Lock: a minimal, non-fair spinlock designed for extremely short critical sections.Wait: an adaptive spin-wait helper that escalates from CPU pause hints to cooperative scheduler yields.Pause: an architecture-specific CPU hint intended for tight busy-wait loops; it must not block or yield the scheduler.
Platform support
Optimized implementations are provided on common architectures, with broad multi-arch support:
amd64, arm64, 386, arm, riscv64, ppc64le, s390x, loong64.
Notes
Lockis intentionally non-fair and is not a general-purpose replacement forsync.Mutex.- For polling loops, prefer
WaitorPauseover ad-hocruntime.Gosched()loops.
Installation
go get code.hybscloud.com/spinChangelog
Added
- Tests for
internal/pause.Pausecovering the main control-flow branches. - An allocation regression guard for
Pauseto keep it allocation-free in hot paths.
Changed
- No production code changes.