diff --git a/src/backend/cpu/CpuBackend.cpp b/src/backend/cpu/CpuBackend.cpp index bdb592fff..f325d0ffa 100644 --- a/src/backend/cpu/CpuBackend.cpp +++ b/src/backend/cpu/CpuBackend.cpp @@ -32,6 +32,7 @@ #include "backend/cpu/CpuBackend.h" #include "base/io/log/Log.h" #include "base/net/stratum/Job.h" +#include "base/tools/Chrono.h" #include "base/tools/String.h" #include "core/config/Config.h" #include "core/Controller.h" @@ -55,6 +56,7 @@ public: started = 0; threads = 0; ways = 0; + ts = Chrono::steadyMSecs(); } size_t hugePages; @@ -63,6 +65,7 @@ public: size_t started; size_t threads; size_t ways; + uint64_t ts; }; @@ -108,6 +111,14 @@ public: profileName = cpu.threads().profileName(job.algorithm()); threads = cpu.threads().get(profileName); + if (profileName.isNull() || threads.empty()) { + workers.stop(); + + LOG_WARN(YELLOW_BOLD_S "CPU disabled, no suitable configuration for algo %s", job.algorithm().shortName()); + + return; + } + LOG_INFO(GREEN_BOLD("CPU") " use profile " BLUE_BG(WHITE_BOLD_S " %s ") WHITE_BOLD_S " (" CYAN_BOLD("%zu") WHITE_BOLD(" threads)") " scratchpad " CYAN_BOLD("%zu KB"), profileName.data(), threads.size(), @@ -217,10 +228,12 @@ void xmrig::CpuBackend::start(IWorker *worker) const double percent = d_ptr->status.hugePages == 0 ? 0.0 : static_cast(d_ptr->status.hugePages) / d_ptr->status.pages * 100.0; const size_t memory = d_ptr->status.ways * d_ptr->status.memory / 1024; - LOG_INFO(GREEN_BOLD("CPU READY") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu KB") "", + LOG_INFO(GREEN_BOLD("CPU READY") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu KB") BLACK_BOLD(" (%" PRIu64 " ms)"), d_ptr->status.threads, d_ptr->status.ways, (d_ptr->status.hugePages == d_ptr->status.pages ? GREEN_BOLD_S : (d_ptr->status.hugePages == 0 ? RED_BOLD_S : YELLOW_BOLD_S)), - d_ptr->status.hugePages, d_ptr->status.pages, percent, memory); + d_ptr->status.hugePages, d_ptr->status.pages, percent, memory, + Chrono::steadyMSecs() - d_ptr->status.ts + ); } uv_mutex_unlock(&d_ptr->mutex); diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index 02ef9c90b..09728b4e7 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -79,15 +79,6 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const doc.AddMember("background", isBackground(), allocator); doc.AddMember("colors", Log::colors, allocator); -// if (affinity() != -1L) { -// snprintf(affinity_tmp, sizeof(affinity_tmp) - 1, "0x%" PRIX64, affinity()); -// doc.AddMember("cpu-affinity", StringRef(affinity_tmp), allocator); -// } -// else { -// doc.AddMember("cpu-affinity", kNullType, allocator); -// } - - doc.AddMember("cpu", m_cpu.toJSON(doc), allocator); doc.AddMember("donate-level", m_pools.donateLevel(), allocator);