Repository navigation
spin v0.1.5 — TTAS slow path with adaptive backoff #9
hayabusa-cloud
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Introduction
Package
spinprovides minimal spin primitives for performance-critical code paths:Lock(non-fair spinlock),Wait(adaptive spin-wait),Pause(architecture-specific CPU hint), andYield(cooperative sleep). Designed for ultra-short critical sections where OS mutex overhead is prohibitive, with zero allocations on hot paths.Lock acquisition uses FAA (Fetch-And-Add) for O(n) coherence traffic under contention, compared to O(n²) with CAS-based spinlocks. Architecture-specific pause instructions are provided for amd64, arm64, riscv64, loong64, ppc64le, s390x, and 386.
Usage
Highlights
Lock slow path rewritten to TTAS (test-and-test-and-set) with local-counter adaptive backoff, reducing cache-line invalidations under contention and guaranteeing forward progress on low-core-count machines.
What's Changed
Improvements
Lockslow path to TTAS: spin on read-onlyLoad, attempt FAA only when lock appears free (TTAS slow path with adaptive backoff #8)Documentation
Locktype and method comments (TTAS slow path with adaptive backoff #8)Try(TTAS slow path with adaptive backoff #8)Chore
Compatibility
This discussion was created from the release spin v0.1.5 — TTAS slow path with adaptive backoff.
All reactions