mirror of
https://github.com/xmrig/xmrig.git
synced 2025-03-12 09:37:35 +00:00
Added information about started threads.
This commit is contained in:
parent
6b4f2d0a91
commit
e2d85d78a7
4 changed files with 65 additions and 5 deletions
|
@ -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];
|
||||
|
|
|
@ -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<uint64_t> m_hashCount;
|
||||
std::atomic<uint64_t> m_timestamp;
|
||||
uint64_t m_count;
|
||||
|
|
|
@ -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<int> Workers::m_paused;
|
||||
std::atomic<uint64_t> Workers::m_sequence;
|
||||
std::list<JobResult> Workers::m_queue;
|
||||
|
@ -109,10 +110,12 @@ void Workers::setJob(const Job &job, bool donate)
|
|||
void Workers::start(xmrig::Controller *controller)
|
||||
{
|
||||
const std::vector<xmrig::IThread *> &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<const Worker *>(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();
|
||||
}
|
||||
|
|
|
@ -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<int> m_paused;
|
||||
static std::atomic<uint64_t> m_sequence;
|
||||
static std::list<JobResult> m_queue;
|
||||
|
|
Loading…
Reference in a new issue