SpinLockConfig

cc.otavia.core.config.SpinLockConfig
case class SpinLockConfig(spinThreshold: Int = ..., yieldThreshold: Int = ..., parkNanos: Long = ...)

Spin lock tuning configuration.

Spin locks use adaptive spinning with progressive backoff through three phases:

  1. Pure spin with Thread.onSpinWait (x86 PAUSE instruction)
  2. Thread.yield to hint the OS scheduler
  3. LockSupport.parkNanos to truly free the CPU core

The critical sections protected by spin locks are typically only a few instructions (pointer assignment + counter update), so uncontended or lightly contended CAS usually succeeds within 1-2 attempts.

Value parameters

parkNanos

Duration in nanoseconds to park in Phase 3. Triggered during long GC STW pauses (10-200ms) where the lock holder is suspended at a safepoint. Default is 1000ns (1μs).

spinThreshold

Number of spin iterations in Phase 1 before switching to yield. Covers the common case of uncontended or lightly contended lock acquisition. Default is 100.

yieldThreshold

Number of spin iterations before switching from yield to park. Entered when the lock holder has been preempted by the OS scheduler or paused by a brief GC event. Default is 200.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product