#1386 Added priority for RandomX dataset initialization threads.
This commit is contained in:
parent
529f394c02
commit
3a75f39935
12 changed files with 45 additions and 26 deletions
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
virtual RxDataset *dataset(const Job &job, uint32_t nodeId) const = 0;
|
virtual RxDataset *dataset(const Job &job, uint32_t nodeId) const = 0;
|
||||||
virtual std::pair<uint32_t, uint32_t> hugePages() const = 0;
|
virtual std::pair<uint32_t, uint32_t> hugePages() const = 0;
|
||||||
virtual void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode) = 0;
|
virtual void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -236,7 +236,9 @@ public:
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
inline bool initRX()
|
inline bool initRX()
|
||||||
{
|
{
|
||||||
return Rx::init(job, controller->config()->rx(), controller->config()->cpu().isHugePages(), controller->config()->cpu().isOneGbPages());
|
const auto &cpu = controller->config()->cpu();
|
||||||
|
|
||||||
|
return Rx::init(job, controller->config()->rx(), cpu.isHugePages(), cpu.isOneGbPages(), cpu.priority());
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ const char *xmrig::rx_tag()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Rx::init(const Job &job, const RxConfig &config, bool hugePages, bool oneGbPages)
|
bool xmrig::Rx::init(const Job &job, const RxConfig &config, bool hugePages, bool oneGbPages, int priority)
|
||||||
{
|
{
|
||||||
if (job.algorithm().family() != Algorithm::RANDOM_X) {
|
if (job.algorithm().family() != Algorithm::RANDOM_X) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -70,7 +70,7 @@ bool xmrig::Rx::init(const Job &job, const RxConfig &config, bool hugePages, boo
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr->queue.enqueue(job, config.nodeset(), config.threads(), hugePages, oneGbPages, config.mode());
|
d_ptr->queue.enqueue(job, config.nodeset(), config.threads(), hugePages, oneGbPages, config.mode(), priority);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class RxDataset;
|
||||||
class Rx
|
class Rx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool init(const Job &job, const RxConfig &config, bool hugePages, bool oneGbPages);
|
static bool init(const Job &job, const RxConfig &config, bool hugePages, bool oneGbPages, int priority);
|
||||||
static bool isReady(const Job &job);
|
static bool isReady(const Job &job);
|
||||||
static RxDataset *dataset(const Job &job, uint32_t nodeId);
|
static RxDataset *dataset(const Job &job, uint32_t nodeId);
|
||||||
static std::pair<uint32_t, uint32_t> hugePages();
|
static std::pair<uint32_t, uint32_t> hugePages();
|
||||||
|
|
|
@ -78,11 +78,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void initDataset(uint32_t threads)
|
inline void initDataset(uint32_t threads, int priority)
|
||||||
{
|
{
|
||||||
const uint64_t ts = Chrono::steadyMSecs();
|
const uint64_t ts = Chrono::steadyMSecs();
|
||||||
|
|
||||||
m_dataset->init(m_seed.data(), threads);
|
m_dataset->init(m_seed.data(), threads, priority);
|
||||||
|
|
||||||
LOG_INFO("%s" GREEN_BOLD("dataset ready") BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
LOG_INFO("%s" GREEN_BOLD("dataset ready") BLACK_BOLD(" (%" PRIu64 " ms)"), rx_tag(), Chrono::steadyMSecs() - ts);
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ std::pair<uint32_t, uint32_t> xmrig::RxBasicStorage::hugePages() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::RxBasicStorage::init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode)
|
void xmrig::RxBasicStorage::init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority)
|
||||||
{
|
{
|
||||||
d_ptr->setSeed(seed);
|
d_ptr->setSeed(seed);
|
||||||
|
|
||||||
|
@ -165,5 +165,5 @@ void xmrig::RxBasicStorage::init(const RxSeed &seed, uint32_t threads, bool huge
|
||||||
d_ptr->createDataset(hugePages, oneGbPages, mode);
|
d_ptr->createDataset(hugePages, oneGbPages, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr->initDataset(threads);
|
d_ptr->initDataset(threads, priority);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
RxDataset *dataset(const Job &job, uint32_t nodeId) const override;
|
RxDataset *dataset(const Job &job, uint32_t nodeId) const override;
|
||||||
std::pair<uint32_t, uint32_t> hugePages() const override;
|
std::pair<uint32_t, uint32_t> hugePages() const override;
|
||||||
void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode) override;
|
void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RxBasicStoragePrivate *d_ptr;
|
RxBasicStoragePrivate *d_ptr;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "crypto/rx/RxDataset.h"
|
#include "crypto/rx/RxDataset.h"
|
||||||
#include "backend/common/Tags.h"
|
#include "backend/common/Tags.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
|
#include "base/kernel/Platform.h"
|
||||||
#include "crypto/common/VirtualMemory.h"
|
#include "crypto/common/VirtualMemory.h"
|
||||||
#include "crypto/rx/RxAlgo.h"
|
#include "crypto/rx/RxAlgo.h"
|
||||||
#include "crypto/rx/RxCache.h"
|
#include "crypto/rx/RxCache.h"
|
||||||
|
@ -40,6 +41,20 @@
|
||||||
static_assert(RANDOMX_FLAG_LARGE_PAGES == 1, "RANDOMX_FLAG_LARGE_PAGES flag mismatch");
|
static_assert(RANDOMX_FLAG_LARGE_PAGES == 1, "RANDOMX_FLAG_LARGE_PAGES flag mismatch");
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, unsigned long startItem, unsigned long itemCount, int priority)
|
||||||
|
{
|
||||||
|
Platform::setThreadPriority(priority);
|
||||||
|
|
||||||
|
randomx_init_dataset(dataset, cache, startItem, itemCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
xmrig::RxDataset::RxDataset(bool hugePages, bool oneGbPages, bool cache, RxConfig::Mode mode) :
|
xmrig::RxDataset::RxDataset(bool hugePages, bool oneGbPages, bool cache, RxConfig::Mode mode) :
|
||||||
m_mode(mode)
|
m_mode(mode)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +82,7 @@ xmrig::RxDataset::~RxDataset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::RxDataset::init(const Buffer &seed, uint32_t numThreads)
|
bool xmrig::RxDataset::init(const Buffer &seed, uint32_t numThreads, int priority)
|
||||||
{
|
{
|
||||||
if (!m_cache) {
|
if (!m_cache) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -88,7 +103,7 @@ bool xmrig::RxDataset::init(const Buffer &seed, uint32_t numThreads)
|
||||||
for (uint64_t i = 0; i < numThreads; ++i) {
|
for (uint64_t i = 0; i < numThreads; ++i) {
|
||||||
const uint32_t a = (datasetItemCount * i) / numThreads;
|
const uint32_t a = (datasetItemCount * i) / numThreads;
|
||||||
const uint32_t b = (datasetItemCount * (i + 1)) / numThreads;
|
const uint32_t b = (datasetItemCount * (i + 1)) / numThreads;
|
||||||
threads.emplace_back(randomx_init_dataset, m_dataset, m_cache->get(), a, b - a);
|
threads.emplace_back(init_dataset_wrapper, m_dataset, m_cache->get(), a, b - a, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < numThreads; ++i) {
|
for (uint32_t i = 0; i < numThreads; ++i) {
|
||||||
|
@ -96,7 +111,7 @@ bool xmrig::RxDataset::init(const Buffer &seed, uint32_t numThreads)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
randomx_init_dataset(m_dataset, m_cache->get(), 0, datasetItemCount);
|
init_dataset_wrapper(m_dataset, m_cache->get(), 0, datasetItemCount, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
inline RxCache *cache() const { return m_cache; }
|
inline RxCache *cache() const { return m_cache; }
|
||||||
inline void setCache(RxCache *cache) { m_cache = cache; }
|
inline void setCache(RxCache *cache) { m_cache = cache; }
|
||||||
|
|
||||||
bool init(const Buffer &seed, uint32_t numThreads);
|
bool init(const Buffer &seed, uint32_t numThreads, int priority);
|
||||||
size_t size(bool cache = true) const;
|
size_t size(bool cache = true) const;
|
||||||
std::pair<uint32_t, uint32_t> hugePages(bool cache = true) const;
|
std::pair<uint32_t, uint32_t> hugePages(bool cache = true) const;
|
||||||
void *raw() const;
|
void *raw() const;
|
||||||
|
|
|
@ -148,13 +148,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void initDatasets(uint32_t threads)
|
inline void initDatasets(uint32_t threads, int priority)
|
||||||
{
|
{
|
||||||
uint64_t ts = Chrono::steadyMSecs();
|
uint64_t ts = Chrono::steadyMSecs();
|
||||||
auto id = m_nodeset.front();
|
auto id = m_nodeset.front();
|
||||||
auto primary = dataset(id);
|
auto primary = dataset(id);
|
||||||
|
|
||||||
primary->init(m_seed.data(), threads);
|
primary->init(m_seed.data(), threads, priority);
|
||||||
|
|
||||||
printDatasetReady(id, ts);
|
printDatasetReady(id, ts);
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ std::pair<uint32_t, uint32_t> xmrig::RxNUMAStorage::hugePages() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::RxNUMAStorage::init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode)
|
void xmrig::RxNUMAStorage::init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode, int priority)
|
||||||
{
|
{
|
||||||
d_ptr->setSeed(seed);
|
d_ptr->setSeed(seed);
|
||||||
|
|
||||||
|
@ -354,5 +354,5 @@ void xmrig::RxNUMAStorage::init(const RxSeed &seed, uint32_t threads, bool hugeP
|
||||||
d_ptr->createDatasets(hugePages, oneGbPages);
|
d_ptr->createDatasets(hugePages, oneGbPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
d_ptr->initDatasets(threads);
|
d_ptr->initDatasets(threads, priority);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
RxDataset *dataset(const Job &job, uint32_t nodeId) const override;
|
RxDataset *dataset(const Job &job, uint32_t nodeId) const override;
|
||||||
std::pair<uint32_t, uint32_t> hugePages() const override;
|
std::pair<uint32_t, uint32_t> hugePages() const override;
|
||||||
void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode) override;
|
void init(const RxSeed &seed, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RxNUMAStoragePrivate *d_ptr;
|
RxNUMAStoragePrivate *d_ptr;
|
||||||
|
|
|
@ -94,7 +94,7 @@ std::pair<uint32_t, uint32_t> xmrig::RxQueue::hugePages()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::RxQueue::enqueue(const RxSeed &seed, const std::vector<uint32_t> &nodeset, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode)
|
void xmrig::RxQueue::enqueue(const RxSeed &seed, const std::vector<uint32_t> &nodeset, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ void xmrig::RxQueue::enqueue(const RxSeed &seed, const std::vector<uint32_t> &no
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_queue.emplace_back(seed, nodeset, threads, hugePages, oneGbPages, mode);
|
m_queue.emplace_back(seed, nodeset, threads, hugePages, oneGbPages, mode, priority);
|
||||||
m_seed = seed;
|
m_seed = seed;
|
||||||
m_state = STATE_PENDING;
|
m_state = STATE_PENDING;
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ void xmrig::RxQueue::backgroundInit()
|
||||||
Buffer::toHex(item.seed.data().data(), 8).data()
|
Buffer::toHex(item.seed.data().data(), 8).data()
|
||||||
);
|
);
|
||||||
|
|
||||||
m_storage->init(item.seed, item.threads, item.hugePages, item.oneGbPages, item.mode);
|
m_storage->init(item.seed, item.threads, item.hugePages, item.oneGbPages, item.mode, item.priority);
|
||||||
|
|
||||||
lock = std::unique_lock<std::mutex>(m_mutex);
|
lock = std::unique_lock<std::mutex>(m_mutex);
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,10 @@ class RxDataset;
|
||||||
class RxQueueItem
|
class RxQueueItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RxQueueItem(const RxSeed &seed, const std::vector<uint32_t> &nodeset, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode) :
|
RxQueueItem(const RxSeed &seed, const std::vector<uint32_t> &nodeset, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority) :
|
||||||
hugePages(hugePages),
|
hugePages(hugePages),
|
||||||
oneGbPages(oneGbPages),
|
oneGbPages(oneGbPages),
|
||||||
|
priority(priority),
|
||||||
mode(mode),
|
mode(mode),
|
||||||
seed(seed),
|
seed(seed),
|
||||||
nodeset(nodeset),
|
nodeset(nodeset),
|
||||||
|
@ -64,6 +65,7 @@ public:
|
||||||
|
|
||||||
const bool hugePages;
|
const bool hugePages;
|
||||||
const bool oneGbPages;
|
const bool oneGbPages;
|
||||||
|
const int priority;
|
||||||
const RxConfig::Mode mode;
|
const RxConfig::Mode mode;
|
||||||
const RxSeed seed;
|
const RxSeed seed;
|
||||||
const std::vector<uint32_t> nodeset;
|
const std::vector<uint32_t> nodeset;
|
||||||
|
@ -82,7 +84,7 @@ public:
|
||||||
bool isReady(const Job &job);
|
bool isReady(const Job &job);
|
||||||
RxDataset *dataset(const Job &job, uint32_t nodeId);
|
RxDataset *dataset(const Job &job, uint32_t nodeId);
|
||||||
std::pair<uint32_t, uint32_t> hugePages();
|
std::pair<uint32_t, uint32_t> hugePages();
|
||||||
void enqueue(const RxSeed &seed, const std::vector<uint32_t> &nodeset, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode);
|
void enqueue(const RxSeed &seed, const std::vector<uint32_t> &nodeset, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum State {
|
enum State {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue