From 4a74ce3242d7e5e678a66eab7996dd8ed41e4fc7 Mon Sep 17 00:00:00 2001 From: cohcho Date: Sat, 10 Oct 2020 13:28:14 +0000 Subject: [PATCH] CPU: use raw counter --- src/backend/common/Workers.cpp | 23 +++++++++++++++++++++++ src/backend/common/Workers.h | 2 ++ src/backend/cpu/CpuWorker.cpp | 13 ------------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/backend/common/Workers.cpp b/src/backend/common/Workers.cpp index 89c44a77b..02b6ab7d0 100644 --- a/src/backend/common/Workers.cpp +++ b/src/backend/common/Workers.cpp @@ -160,6 +160,29 @@ void xmrig::Workers::tick(uint64_t) } +template<> +void xmrig::Workers::tick(uint64_t) +{ + if (!d_ptr->hashrate) { + return; + } + + const uint64_t timestamp = Chrono::steadyMSecs(); + uint64_t totalHashCount = 0; + for (Thread *handle : m_workers) { + if (handle->worker()) { + const uint64_t hashCount = handle->worker()->rawHashes(); + d_ptr->hashrate->add(handle->id() + 1, hashCount, timestamp); + totalHashCount += hashCount; + } + } + + if (totalHashCount > 0) { + d_ptr->hashrate->add(0, totalHashCount, timestamp); + } +} + + template xmrig::IWorker *xmrig::Workers::create(Thread *) { diff --git a/src/backend/common/Workers.h b/src/backend/common/Workers.h index bd43e0102..022009607 100644 --- a/src/backend/common/Workers.h +++ b/src/backend/common/Workers.h @@ -88,6 +88,8 @@ void xmrig::Workers::jobEarlyNotification(const Job& job) template<> IWorker *Workers::create(Thread *handle); +template<> +void Workers::tick(uint64_t); extern template class Workers; diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 8565acfb8..e49f158fb 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -211,25 +211,12 @@ void xmrig::CpuWorker::start() consumeJob(); } - uint64_t storeStatsMask = 7; - # ifdef XMRIG_ALGO_RANDOMX bool first = true; alignas(16) uint64_t tempHash[8] = {}; - - // RandomX is faster, we don't need to store stats so often -# ifndef XMRIG_ARM - if (m_job.currentJob().algorithm().family() == Algorithm::RANDOM_X) { - storeStatsMask = 63; - } -# endif # endif while (!Nonce::isOutdated(Nonce::CPU, m_job.sequence())) { - if ((m_count & storeStatsMask) == 0) { - storeStats(); - } - const Job &job = m_job.currentJob(); if (job.algorithm().l3() != m_algorithm.l3()) {