Repository navigation
spin v0.1.3 — 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
Bug Fixes
- loong64: Fix
pauseNusing zero register (R0 → R4) - riscv64: Use
PAUSEhint (Zihintpause) instead ofFENCE