From 26ed6254dc88158e62cfe88a215d5e880749b481 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 1 Nov 2019 04:08:52 +0700 Subject: [PATCH] Added "health-print-time" option. --- README.md | 2 ++ src/backend/cuda/CudaBackend.cpp | 7 +++++ src/base/kernel/interfaces/IConfig.h | 4 ++- src/config.json | 4 +++ src/core/Miner.cpp | 3 +- src/core/config/Config.cpp | 44 +++++++++++++++++++++------- src/core/config/Config.h | 4 +++ src/core/config/ConfigTransform.cpp | 8 +++++ src/core/config/Config_default.h | 4 +++ src/core/config/Config_platform.h | 4 +++ src/core/config/usage.h | 6 ++++ 11 files changed, 78 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index cffb28c7a..fa2e814ad 100644 --- a/README.md +++ b/README.md @@ -84,11 +84,13 @@ OpenCL backend: CUDA backend: --cuda enable CUDA mining backend --cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so) + --no-nvml disable NVML (NVIDIA Management Library) support Logging: -S, --syslog use system log for output messages -l, --log-file=FILE log all output to a file --print-time=N print hashrate report every N seconds + --health-print-time=N print health report every N seconds --no-color disable colored output Misc: diff --git a/src/backend/cuda/CudaBackend.cpp b/src/backend/cuda/CudaBackend.cpp index 6bc0d81ca..feb1dd93f 100644 --- a/src/backend/cuda/CudaBackend.cpp +++ b/src/backend/cuda/CudaBackend.cpp @@ -452,6 +452,13 @@ void xmrig::CudaBackend::stop() void xmrig::CudaBackend::tick(uint64_t ticks) { d_ptr->workers.tick(ticks); + +# ifdef XMRIG_FEATURE_NVML + auto seconds = d_ptr->controller->config()->healthPrintTime(); + if (seconds && ticks && (ticks % (seconds * 2)) == 0) { + d_ptr->printHealth(); + } +# endif } diff --git a/src/base/kernel/interfaces/IConfig.h b/src/base/kernel/interfaces/IConfig.h index ccee47c67..7167e0bb7 100644 --- a/src/base/kernel/interfaces/IConfig.h +++ b/src/base/kernel/interfaces/IConfig.h @@ -135,7 +135,9 @@ public: CudaAffinityKey = 1205, CudaMaxUsageKey = 1206, CudaKey = 1207, - CudaLoaderKey = 1208 + CudaLoaderKey = 1208, + NvmlKey = 1209, + HealthPrintTimeKey = 1210, }; virtual ~IConfig() = default; diff --git a/src/config.json b/src/config.json index 9c6d459e2..fbc60474a 100644 --- a/src/config.json +++ b/src/config.json @@ -41,6 +41,9 @@ "cuda": { "enabled": false, "loader": null, + "nvml": true, + "cn/0": false, + "cn-lite/0": false }, "donate-level": 5, "donate-over-proxy": 1, @@ -63,6 +66,7 @@ } ], "print-time": 60, + "health-print-time": 60, "retries": 5, "retry-pause": 5, "syslog": false, diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index a28ccbbfe..20ff3fd73 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -494,7 +494,8 @@ void xmrig::Miner::onTimer(const Timer *) d_ptr->maxHashrate[d_ptr->algorithm] = std::max(d_ptr->maxHashrate[d_ptr->algorithm], maxHashrate); - if ((d_ptr->ticks % (d_ptr->controller->config()->printTime() * 2)) == 0) { + auto seconds = d_ptr->controller->config()->printTime(); + if (seconds && (d_ptr->ticks % (seconds * 2)) == 0) { printHashrate(false); } diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index 4fd88b90e..a445961f1 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -70,6 +70,11 @@ static const char *kCuda = "cuda"; #endif +#if defined(XMRIG_FEATURE_NVML) +static const char *kHealthPrintTime = "health-print-time"; +#endif + + class ConfigPrivate { public: @@ -86,6 +91,10 @@ public: # ifdef XMRIG_FEATURE_CUDA CudaConfig cuda; # endif + +# if defined(XMRIG_FEATURE_NVML) + uint32_t healthPrintTime = 60; +# endif }; } @@ -133,6 +142,14 @@ const xmrig::RxConfig &xmrig::Config::rx() const #endif +#if defined(XMRIG_FEATURE_NVML) +uint32_t xmrig::Config::healthPrintTime() const +{ + return d_ptr->healthPrintTime; +} +#endif + + bool xmrig::Config::isShouldSave() const { if (!isAutoSave()) { @@ -177,6 +194,10 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName) d_ptr->cuda.read(reader.getValue(kCuda)); # endif +# ifdef XMRIG_FEATURE_NVML + d_ptr->healthPrintTime = reader.getUint(kHealthPrintTime, d_ptr->healthPrintTime); +# endif + return true; } @@ -213,14 +234,17 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const doc.AddMember(StringRef(kCuda), cuda().toJSON(doc), allocator); # endif - doc.AddMember("donate-level", m_pools.donateLevel(), allocator); - doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator); - doc.AddMember("log-file", m_logFile.toJSON(), allocator); - doc.AddMember("pools", m_pools.toJSON(doc), allocator); - doc.AddMember("print-time", printTime(), allocator); - doc.AddMember("retries", m_pools.retries(), allocator); - doc.AddMember("retry-pause", m_pools.retryPause(), allocator); - doc.AddMember("syslog", isSyslog(), allocator); - doc.AddMember("user-agent", m_userAgent.toJSON(), allocator); - doc.AddMember("watch", m_watch, allocator); + doc.AddMember("donate-level", m_pools.donateLevel(), allocator); + doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator); + doc.AddMember("log-file", m_logFile.toJSON(), allocator); + doc.AddMember("pools", m_pools.toJSON(doc), allocator); + doc.AddMember("print-time", printTime(), allocator); +# if defined(XMRIG_FEATURE_NVML) + doc.AddMember(StringRef(kHealthPrintTime), healthPrintTime(), allocator); +# endif + doc.AddMember("retries", m_pools.retries(), allocator); + doc.AddMember("retry-pause", m_pools.retryPause(), allocator); + doc.AddMember("syslog", isSyslog(), allocator); + doc.AddMember("user-agent", m_userAgent.toJSON(), allocator); + doc.AddMember("watch", m_watch, allocator); } diff --git a/src/core/config/Config.h b/src/core/config/Config.h index 8becc0b80..5eb91ecae 100644 --- a/src/core/config/Config.h +++ b/src/core/config/Config.h @@ -67,6 +67,10 @@ public: const RxConfig &rx() const; # endif +# if defined(XMRIG_FEATURE_NVML) + uint32_t healthPrintTime() const; +# endif + bool isShouldSave() const; bool read(const IJsonReader &reader, const char *fileName) override; void getJSON(rapidjson::Document &doc) const override; diff --git a/src/core/config/ConfigTransform.cpp b/src/core/config/ConfigTransform.cpp index 51f594e8b..ffd3fbd8e 100644 --- a/src/core/config/ConfigTransform.cpp +++ b/src/core/config/ConfigTransform.cpp @@ -193,6 +193,14 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const return set(doc, kCuda, "loader", arg); # endif +# ifdef XMRIG_FEATURE_NVML + case IConfig::NvmlKey: /* --no-nvml */ + return set(doc, kCuda, "nvml", false); + + case IConfig::HealthPrintTimeKey: /* --health-print-time */ + return set(doc, "health-print-time", static_cast(strtol(arg, nullptr, 10))); +# endif + default: break; } diff --git a/src/core/config/Config_default.h b/src/core/config/Config_default.h index e7d39299f..afd3638bb 100644 --- a/src/core/config/Config_default.h +++ b/src/core/config/Config_default.h @@ -75,6 +75,9 @@ R"===( "cuda": { "enabled": false, "loader": null, + "nvml": true, + "cn/0": false, + "cn-lite/0": false }, "donate-level": 5, "donate-over-proxy": 1, @@ -97,6 +100,7 @@ R"===( } ], "print-time": 60, + "health-print-time": 60, "retries": 5, "retry-pause": 5, "syslog": false, diff --git a/src/core/config/Config_platform.h b/src/core/config/Config_platform.h index 371e58fa8..3309bebaf 100644 --- a/src/core/config/Config_platform.h +++ b/src/core/config/Config_platform.h @@ -107,6 +107,10 @@ static const option options[] = { # ifdef XMRIG_FEATURE_CUDA { "cuda", 0, nullptr, IConfig::CudaKey }, { "cuda-loader", 1, nullptr, IConfig::CudaLoaderKey }, +# endif +# ifdef XMRIG_FEATURE_NVML + { "no-nvml", 0, nullptr, IConfig::NvmlKey }, + { "health-print-time", 1, nullptr, IConfig::HealthPrintTimeKey }, # endif { nullptr, 0, nullptr, 0 } }; diff --git a/src/core/config/usage.h b/src/core/config/usage.h index c95526f78..d9ef23169 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -113,6 +113,9 @@ static inline const std::string &usage() u += " --cuda enable CUDA mining backend\n"; u += " --cuda-loader=PATH path to CUDA plugin (xmrig-cuda.dll or libxmrig-cuda.so)\n"; # endif +# ifdef XMRIG_FEATURE_NVML + u += " --no-nvml disable NVML (NVIDIA Management Library) support\n"; +# endif u += "\nLogging:\n"; @@ -122,6 +125,9 @@ static inline const std::string &usage() u += " -l, --log-file=FILE log all output to a file\n"; u += " --print-time=N print hashrate report every N seconds\n"; +# ifdef XMRIG_FEATURE_NVML + u += " --health-print-time=N print health report every N seconds\n"; +# endif u += " --no-color disable colored output\n"; u += "\nMisc:\n";