Skip to content

fix(tune): an interrupted live sweep restores the pre-sweep config (#347) - #359

Merged
VijitSingh97 merged 3 commits into
developfrom
fix/347-tune-live-restore
Aug 15, 2026
Merged

fix(tune): an interrupted live sweep restores the pre-sweep config (#347)#359
VijitSingh97 merged 3 commits into
developfrom
fix/347-tune-live-restore

Conversation

@VijitSingh97

Copy link
Copy Markdown
Contributor

tune --live wrote each candidate into tune-overrides.json and restarted the miner per trial; the EXIT trap restored the service and tmp but never the overrides — Ctrl+C or a shutdown mid-sweep left an arbitrary losing config persisted through every future apply. Same class in autotune's per-trial prefetch. The trap now restores pre_overrides (and the prefetch) via the same code path the clean-completion route uses, ordered before the final service restart so the miner comes back on the restored config — abort and success cannot diverge.

Tests: aborted-live-sweep sections asserting tune-overrides.json equals pre-sweep content and the service saw its final restart. CHANGELOG entry included. Live proof rides the release e2e-real.

Closes #347

🤖 Generated with Claude Code

VijitSingh97 and others added 3 commits August 14, 2026 19:50
…ed (#347)

An interrupted tune --live (or autotune / tune --now) persisted whatever
mid-sweep candidate was in flight: _measure_live writes each candidate into
tune-overrides.json and restarts the miner on it, but the EXIT trap only
cleaned the temp dir and restarted a bench-stopped service — the candidate
stayed saved AND running, silently costing hashrate until the next re-tune.

Mechanism: tune() snapshots the pre-sweep overrides and marks the file dirty
for the duration of a live sweep; the existing EXIT trap (which bash runs on
INT/TERM/HUP and on errexit) now restores that snapshot FIRST — through
_restore_overrides, the exact restore+apply step the --confirm revert leg
already used, factored out so the abort path cannot diverge from the
completion path — before any other service handling, so every later restart
re-reads the restored file. The winner write clears the flag: a completed
decision stands down the abort-restore.

autotune gets the same protection via its own EXIT trap: the pre-sweep
prefetch mode is re-merged with _autotune_set_prefetch (the sweep's own
write path, shared via _autotune_settle with the clean-completion tail), so
knobs pinned by an offline tune survive the abort exactly as they survive a
completed run.

Tests: two black-box sections kill the real process mid-iteration (the fake
API flags the candidate window, then blocks; exec makes the backgrounded PID
the trap-owning shell) and assert the overrides come back byte-identical
(tune --live) / mode-restored with merged knobs intact (autotune), plus a
post-kill service restart. All six behavior asserts fail on the unfixed
script.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@VijitSingh97
VijitSingh97 merged commit 8ff692d into develop Aug 15, 2026
9 checks passed
@VijitSingh97
VijitSingh97 deleted the fix/347-tune-live-restore branch August 15, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interrupted tune --live / autotune persists the mid-sweep candidate — a losing config survives every future apply

1 participant