Skip to content

spin v0.1.2 — low-latency spin primitives for Go

Choose a tag to compare

@hayabusa-cloud hayabusa-cloud released this 16 Dec 12:41
· 14 commits to main since this release
8f6b9c3

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

  • Lock is intentionally non-fair and is not a general-purpose replacement for sync.Mutex.
  • For polling loops, prefer Wait or Pause over ad-hoc runtime.Gosched() loops.

Installation

go get code.hybscloud.com/spin

Changelog

Added

  • Tests for internal/pause.Pause covering the main control-flow branches.
  • An allocation regression guard for Pause to keep it allocation-free in hot paths.

Changed

  • No production code changes.