fix(tune): an interrupted live sweep restores the pre-sweep config (#347) - #359
Merged
Conversation
…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>
…restore # Conflicts: # CHANGELOG.md
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tune --livewrote 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 restorespre_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