From 7f2f50a8d91f2a12f734ec6145d734097007db7c Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sat, 25 Dec 2021 13:39:15 +0100 Subject: [PATCH] RandomX: don't restart mining threads when the seed changes It helps to not loose huge pages when the seed changes (every 2048 blocks, ~2.8 days). --- src/backend/cpu/CpuWorker.cpp | 4 ++-- src/core/Miner.cpp | 8 +++++++- src/crypto/rx/RxQueue.cpp | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 5a6ae8fa..c5037a0e 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -134,7 +134,7 @@ void xmrig::CpuWorker::allocateRandomX_VM() RxDataset *dataset = Rx::dataset(m_job.currentJob(), node()); while (dataset == nullptr) { - std::this_thread::sleep_for(std::chrono::milliseconds(200)); + std::this_thread::sleep_for(std::chrono::milliseconds(20)); if (Nonce::sequence(Nonce::CPU) == 0) { return; @@ -246,7 +246,7 @@ void xmrig::CpuWorker::start() while (Nonce::sequence(Nonce::CPU) > 0) { if (Nonce::isPaused()) { do { - std::this_thread::sleep_for(std::chrono::milliseconds(200)); + std::this_thread::sleep_for(std::chrono::milliseconds(20)); } while (Nonce::isPaused() && Nonce::sequence(Nonce::CPU) > 0); diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 78ed1f6a..8bfccd64 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -553,7 +553,13 @@ void xmrig::Miner::setJob(const Job &job, bool donate) # ifdef XMRIG_ALGO_RANDOMX if (job.algorithm().family() == Algorithm::RANDOM_X && !Rx::isReady(job)) { - stop(); + if (d_ptr->algorithm != job.algorithm()) { + stop(); + } + else { + Nonce::pause(true); + Nonce::touch(); + } } # endif diff --git a/src/crypto/rx/RxQueue.cpp b/src/crypto/rx/RxQueue.cpp index 86b63327..489a7bc7 100644 --- a/src/crypto/rx/RxQueue.cpp +++ b/src/crypto/rx/RxQueue.cpp @@ -154,6 +154,8 @@ void xmrig::RxQueue::backgroundInit() continue; } + // Update seed here again in case there was more than one item in the queue + m_seed = item.seed; m_state = STATE_IDLE; m_async->send(); }