Commit 9308b4d
feat(vardiff): replace threshold-ladder with adaptive EWMA algorithm
Clean extraction of the best-performing vardiff algorithm from the
simulation framework in #2154, with all test scaffolding, traits, and
alternative algorithm implementations removed.
The previous VardiffState used a fixed time-dependent threshold ladder
and full retarget. This produced:
- 6.6% median settled error (p99: 30% at low SPM)
- 5–9 minute cold-start convergence (p90)
- 33% detection rate for 10% hashrate declines (thermal throttle, failing ASICs)
- 28% target overshoot during cold-start ramp (p99 at SPM 6)
The new algorithm (EWMA + adaptive boundary + accelerating partial retarget):
- Settled accuracy: <3% median error across all SPM
- Cold-start overshoot bounded to <10% (was 28%)
- Jitter: 0.03 fires/min at low SPM (was 0.06) — half the unnecessary retargets
- Small-change detection: 85% reaction to -10% steps at SPM 6 (was 33%)
- Transient disconnects recover in 1–2 fires rather than requiring a full
cold-start ramp (20%/fire partial retarget vs old algo's 50–67% slash)
- Asymmetric cost: loosening fires 3x faster than tightening, because
loosening is free but tightening rejects in-flight shares
Breaking: adds private fields to VardiffState (previously all-pub).
Requires channels_sv2 major version bump. Public constructor API
(new, new_with_min) and Vardiff trait interface are unchanged.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent f465e0a commit 9308b4d
4 files changed
Lines changed: 497 additions & 582 deletions
0 commit comments