#1385 "max-threads-hint" option now also limit RandomX dataset initialization threads.

This commit is contained in:
XMRig 2019-12-07 22:18:06 +07:00
parent 3a75f39935
commit e9e747f0d1
No known key found for this signature in database
GPG key ID: 446A53638BE94409
8 changed files with 21 additions and 14 deletions

View file

@ -61,6 +61,7 @@ public:
inline const String &argon2Impl() const { return m_argon2Impl; }
inline const Threads<CpuThreads> &threads() const { return m_threads; }
inline int priority() const { return m_priority; }
inline uint32_t limit() const { return m_limit; }
private:
void generate();

View file

@ -23,7 +23,7 @@
*/
#include <algorithm>
#include <string.h>
#include <cstring>
#include <thread>

View file

@ -262,7 +262,7 @@ xmrig::CpuThreads xmrig::HwlocCpuInfo::threads(const Algorithm &algorithm, uint3
void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorithm &algorithm, CpuThreads &threads, size_t limit) const
{
constexpr size_t oneMiB = 1024u * 1024u;
constexpr size_t oneMiB = 1024U * 1024U;
size_t PUs = countByType(cache, HWLOC_OBJ_PU);
if (PUs == 0) {

View file

@ -234,12 +234,7 @@ public:
# ifdef XMRIG_ALGO_RANDOMX
inline bool initRX()
{
const auto &cpu = controller->config()->cpu();
return Rx::init(job, controller->config()->rx(), cpu.isHugePages(), cpu.isOneGbPages(), cpu.priority());
}
inline bool initRX() { return Rx::init(job, controller->config()->rx(), controller->config()->cpu()); }
# endif

View file

@ -27,6 +27,7 @@
#include "crypto/rx/Rx.h"
#include "backend/common/Tags.h"
#include "backend/cpu/CpuConfig.h"
#include "base/io/log/Log.h"
#include "crypto/rx/RxConfig.h"
#include "crypto/rx/RxQueue.h"
@ -60,7 +61,7 @@ const char *xmrig::rx_tag()
}
bool xmrig::Rx::init(const Job &job, const RxConfig &config, bool hugePages, bool oneGbPages, int priority)
bool xmrig::Rx::init(const Job &job, const RxConfig &config, const CpuConfig &cpu)
{
if (job.algorithm().family() != Algorithm::RANDOM_X) {
return true;
@ -70,7 +71,7 @@ bool xmrig::Rx::init(const Job &job, const RxConfig &config, bool hugePages, boo
return true;
}
d_ptr->queue.enqueue(job, config.nodeset(), config.threads(), hugePages, oneGbPages, config.mode(), priority);
d_ptr->queue.enqueue(job, config.nodeset(), config.threads(cpu.limit()), cpu.isHugePages(), cpu.isOneGbPages(), config.mode(), cpu.priority());
return false;
}

View file

@ -37,6 +37,7 @@ namespace xmrig
class Algorithm;
class CpuConfig;
class IRxListener;
class Job;
class RxConfig;
@ -46,7 +47,7 @@ class RxDataset;
class Rx
{
public:
static bool init(const Job &job, const RxConfig &config, bool hugePages, bool oneGbPages, int priority);
static bool init(const Job &job, const RxConfig &config, const CpuConfig &cpu);
static bool isReady(const Job &job);
static RxDataset *dataset(const Job &job, uint32_t nodeId);
static std::pair<uint32_t, uint32_t> hugePages();

View file

@ -30,6 +30,7 @@
#include <array>
#include <algorithm>
#include <cmath>
#ifdef _MSC_VER
@ -52,9 +53,17 @@ const char *xmrig::RxConfig::modeName() const
}
uint32_t xmrig::RxConfig::threads() const
uint32_t xmrig::RxConfig::threads(uint32_t limit) const
{
return m_threads < 1 ? static_cast<uint32_t>(Cpu::info()->threads()) : static_cast<uint32_t>(m_threads);
if (m_threads > 0) {
return m_threads;
}
if (limit < 100) {
return std::max(static_cast<uint32_t>(round(Cpu::info()->threads() * (limit / 100.0))), 1U);
}
return Cpu::info()->threads();
}

View file

@ -55,7 +55,7 @@ public:
# endif
const char *modeName() const;
uint32_t threads() const;
uint32_t threads(uint32_t limit = 100) const;
inline Mode mode() const { return m_mode; }