NitroSpinStats class

Observability for the single-in-flight completion spin (issue #57).

The spin self-tunes per library (it sizes its window to the recent completion latency and backs off when spinning stops paying), so these aggregate counters let you confirm it is actually winning before you widen NitroConfig.nativeAsyncSpinUs — or notice it never helps and turn it off.

final s = NitroSpinStats.instance;
print('spin hit-rate ${(s.hitRate * 100).toStringAsFixed(0)}% '
      'avg ${s.avgHitUs.toStringAsFixed(1)}µs over ${s.spins} calls');

Properties

avgHitUs → double
Mean microseconds a hit took from spin start to the completion landing.
no setter
avgMissUs → double
Mean true completion latency of the calls that missed the window — measured uncensored (arm → port delivery), so it reflects how slow the missed completions really were, not the window. avgMissUs far above avgHitUs with a low hitRate means the workload is bimodal (a fast mode the spin catches plus a slow tail it can't) — the only shape where sizing the window below the cap could help. When it's empty or ≈ avgHitUs the workload is unimodal and the fixed cap is already near-optimal.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hitRate → double
Fraction of spins that landed off-port, 0 when nothing has spun yet.
no setter
hits ↔ int
Completions picked up from the slot — no port message, no OS wake.
getter/setter pair
misses ↔ int
Completions that parked and came back through the port instead.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
spins → int
Native-async calls that attempted a spin.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recordHit(int us) → void
recordMiss() → void
recordMissLatency(int us) → void
The uncensored latency of a missed completion, recorded when its port message finally arrives (see NitroCompletionBatch). Separate from recordMiss because the latency isn't known until later.
reset() → void
Clears the counters (e.g. between benchmark phases or in tests).
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

instance → NitroSpinStats
final