From e2d85d78a7e89ad062f68706a93a6aa3367cb4c6 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 15 Apr 2018 14:49:39 +0700 Subject: [PATCH] Added information about started threads. --- src/workers/MultiWorker.h | 1 - src/workers/Worker.h | 3 +++ src/workers/Workers.cpp | 41 +++++++++++++++++++++++++++++++++++---- src/workers/Workers.h | 25 ++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/src/workers/MultiWorker.h b/src/workers/MultiWorker.h index ba57f81e..2c231e8d 100644 --- a/src/workers/MultiWorker.h +++ b/src/workers/MultiWorker.h @@ -64,7 +64,6 @@ private: cryptonight_ctx *m_ctx[N]; - MemInfo m_memory; State m_pausedState; State m_state; uint8_t m_hash[N * 32]; diff --git a/src/workers/Worker.h b/src/workers/Worker.h index 0ae30530..aad9e3c5 100644 --- a/src/workers/Worker.h +++ b/src/workers/Worker.h @@ -30,6 +30,7 @@ #include "interfaces/IWorker.h" +#include "Mem.h" struct cryptonight_ctx; @@ -46,6 +47,7 @@ class Worker : public IWorker public: Worker(Handle *handle); + inline const MemInfo &memory() const { return m_memory; } inline size_t id() const override { return m_id; } inline uint64_t hashCount() const override { return m_hashCount.load(std::memory_order_relaxed); } inline uint64_t timestamp() const override { return m_timestamp.load(std::memory_order_relaxed); } @@ -56,6 +58,7 @@ protected: const size_t m_id; const size_t m_totalWays; const uint32_t m_offset; + MemInfo m_memory; std::atomic m_hashCount; std::atomic m_timestamp; uint64_t m_count; diff --git a/src/workers/Workers.cpp b/src/workers/Workers.cpp index 21379db4..6d6deb3b 100644 --- a/src/workers/Workers.cpp +++ b/src/workers/Workers.cpp @@ -43,6 +43,7 @@ bool Workers::m_enabled = true; Hashrate *Workers::m_hashrate = nullptr; IJobResultListener *Workers::m_listener = nullptr; Job Workers::m_job; +Workers::LaunchStatus Workers::m_status; std::atomic Workers::m_paused; std::atomic Workers::m_sequence; std::list Workers::m_queue; @@ -109,10 +110,12 @@ void Workers::setJob(const Job &job, bool donate) void Workers::start(xmrig::Controller *controller) { const std::vector &threads = controller->config()->threads(); + m_status.algo = controller->config()->algorithm(); + m_status.colors = controller->config()->isHugePages(); + m_status.threads = threads.size(); - size_t totalWays = 0; for (const xmrig::IThread *thread : threads) { - totalWays += thread->multiway(); + m_status.ways += thread->multiway(); } m_hashrate = new Hashrate(threads.size(), controller); @@ -130,7 +133,7 @@ void Workers::start(xmrig::Controller *controller) uint32_t offset = 0; for (xmrig::IThread *thread : threads) { - Handle *handle = new Handle(thread, offset, totalWays); + Handle *handle = new Handle(thread, offset, m_status.ways); offset += thread->multiway(); m_workers.push_back(handle); @@ -203,7 +206,7 @@ void Workers::onReady(void *arg) return; } - worker->start(); + start(worker); } @@ -244,3 +247,33 @@ void Workers::onTick(uv_timer_t *handle) Api::tick(m_hashrate); # endif } + + +void Workers::start(IWorker *worker) +{ + const Worker *w = static_cast(worker); + + uv_mutex_lock(&m_mutex); + m_status.started++; + m_status.pages += w->memory().pages; + m_status.hugePages += w->memory().hugePages; + + if (m_status.started == m_status.threads) { + const double percent = (double) m_status.hugePages / m_status.pages * 100.0; + + if (m_status.colors) { + LOG_INFO("\x1B[01;32mREADY (CPU)\x1B[0m threads \x1B[01;36m%zu(%zu)\x1B[0m huge pages %s%zu/%zu %1.0f%%\x1B[0m memory \x1B[01;36m%zu.0 MB", + m_status.threads, m_status.ways, + (m_status.hugePages == m_status.pages ? "\x1B[01;32m" : (m_status.hugePages == 0 ? "\x1B[01;31m" : "\x1B[01;33m")), + m_status.hugePages, m_status.pages, percent, m_status.pages * 2); + } + else { + LOG_INFO("READY (CPU) threads %zu(%zu) huge pages %zu/%zu %f%% memory %zu.0 MB", + m_status.threads, m_status.ways, m_status.hugePages, m_status.pages, percent, m_status.pages * 2); + } + } + + uv_mutex_unlock(&m_mutex); + + worker->start(); +} diff --git a/src/workers/Workers.h b/src/workers/Workers.h index ecec9e30..81b3411a 100644 --- a/src/workers/Workers.h +++ b/src/workers/Workers.h @@ -37,6 +37,7 @@ class Handle; class Hashrate; class IJobResultListener; +class IWorker; namespace xmrig { @@ -66,12 +67,36 @@ private: static void onReady(void *arg); static void onResult(uv_async_t *handle); static void onTick(uv_timer_t *handle); + static void start(IWorker *worker); + + class LaunchStatus + { + public: + inline LaunchStatus() : + colors(true), + hugePages(0), + pages(0), + started(0), + threads(0), + ways(0), + algo(xmrig::CRYPTONIGHT) + {} + + bool colors; + size_t hugePages; + size_t pages; + size_t started; + size_t threads; + size_t ways; + xmrig::Algo algo; + }; static bool m_active; static bool m_enabled; static Hashrate *m_hashrate; static IJobResultListener *m_listener; static Job m_job; + static LaunchStatus m_status; static std::atomic m_paused; static std::atomic m_sequence; static std::list m_queue;