perf(mining): one save, at most one restart per thread-count gesture
Every thread-count change on the Mining tab saved settings.json and, with a miner running, stopped and restarted it: xmrig re-inits its RandomX dataset and reconnects to the pool, seconds of lost hashing each time. A drag across the grid did this once per tile crossed (up to ~24), with a "Starting pool miner" toast each; every -/+ click or Enter did it again. The tab now hands each pick to the App, which puts the newest in settings at once and applies it when the input settles: on drag release, or 0.5 s after the last click, even if the Mining tab was left in the meantime. The header, RAM estimate and tile fill still follow the drag live. - Pool: the restart is decided on the mining-control thread, after every earlier start or stop has run. It never starts a miner the user stopped, is a no-op when xmrig already runs at that count, and is no longer silently skipped when the pick lands in another restart's stop window (which left xmrig on the old count). - Solo: one setgenerate per gesture. A pick made while one is in flight now waits for it instead of being dropped (another stale count). - Clicking the tile that is already selected does nothing; it used to save settings and restart the miner. - With idle thread scaling on, the grid no longer snaps back to the old count while a pick is on its way to the miner. A pool auto-balance restart keeps a count still queued. - Idle thread scaling changes the pool count through the same retarget. Its correction after a start compares with the count last requested, not the xmrig API's lagging report, so it comes about 1 s in instead of after the first API report (3-5 s). - A retarget whose pool config no longer validates shows the same error and stops the miner, as the old stop-then-start did. - While a benchmark runs a pick is saved, but the miner change is dropped: the benchmark owns the count until it ends. A crash within 0.5 s of a pick, or mid-drag, loses that pick; every clean exit saves it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+7
-1
@@ -264,7 +264,9 @@ void App::applyPoolAutoBalance(const util::PoolStatsService::Snapshot& snap)
|
||||
|
||||
// Restart so the new pool (and its per-pool algo) takes effect immediately.
|
||||
if (xmrig_manager_ && xmrig_manager_->isRunning()) {
|
||||
const int threads = xmrig_manager_->getRequestedThreads();
|
||||
// A thread-count retarget may still be queued on the control thread: keep its count, not the old one.
|
||||
const int queued = pool_threads_target_.load(std::memory_order_relaxed);
|
||||
const int threads = queued > 0 ? queued : xmrig_manager_->getRequestedThreads();
|
||||
stopPoolMining();
|
||||
startPoolMining(threads);
|
||||
}
|
||||
@@ -994,6 +996,9 @@ void App::update()
|
||||
checkAutoLock();
|
||||
}
|
||||
|
||||
// Apply a settled mining thread-count pick: one settings save + at most one miner change per gesture.
|
||||
tickMiningThreadCommit();
|
||||
|
||||
// Mine-when-idle check (cheap on most frames: it gates itself to 1 Hz)
|
||||
checkIdleMining();
|
||||
|
||||
@@ -1131,6 +1136,7 @@ void App::update()
|
||||
state_.pool_mining.hashrate_60s = 0.0;
|
||||
state_.pool_mining.hashrate_15m = 0.0;
|
||||
pool_starting_.store(false, std::memory_order_relaxed);
|
||||
pool_threads_target_.store(0, std::memory_order_relaxed); // that miner is gone
|
||||
const std::string err = xmrig_manager_->getLastError();
|
||||
ui::Notifications::instance().error(err.empty() ? TR("appx_miner_stopped_unexpectedly")
|
||||
: (std::string(TR("appx_miner_stopped_prefix")) + err));
|
||||
|
||||
Reference in New Issue
Block a user