mirror of
https://github.com/xmrig/xmrig.git
synced 2025-03-23 23:58:53 +00:00
Always stop mining threads in RandomX dataset change upcoming.
This commit is contained in:
parent
bdaf28adf8
commit
f7ea4b6dbd
5 changed files with 35 additions and 14 deletions
|
@ -49,7 +49,8 @@ namespace xmrig {
|
||||||
extern template class Threads<CpuThread>;
|
extern template class Threads<CpuThread>;
|
||||||
|
|
||||||
|
|
||||||
static const String kType = "cpu";
|
static const char *tag = CYAN_BG_BOLD(" cpu ");
|
||||||
|
static const String kType = "cpu";
|
||||||
|
|
||||||
|
|
||||||
struct LaunchStatus
|
struct LaunchStatus
|
||||||
|
@ -94,7 +95,8 @@ public:
|
||||||
|
|
||||||
inline void start()
|
inline void start()
|
||||||
{
|
{
|
||||||
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"),
|
LOG_INFO("%s use profile " BLUE_BG(WHITE_BOLD_S " %s ") WHITE_BOLD_S " (" CYAN_BOLD("%zu") WHITE_BOLD(" threads)") " scratchpad " CYAN_BOLD("%zu KB"),
|
||||||
|
tag,
|
||||||
profileName.data(),
|
profileName.data(),
|
||||||
threads.size(),
|
threads.size(),
|
||||||
algo.memory() / 1024
|
algo.memory() / 1024
|
||||||
|
@ -170,12 +172,8 @@ const xmrig::String &xmrig::CpuBackend::type() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::CpuBackend::prepare(const Job &nextJob)
|
void xmrig::CpuBackend::prepare(const Job &)
|
||||||
{
|
{
|
||||||
if (nextJob.algorithm().family() == Algorithm::RANDOM_X && nextJob.algorithm() != d_ptr->algo) {
|
|
||||||
d_ptr->workers.stop();
|
|
||||||
d_ptr->threads.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -207,9 +205,7 @@ void xmrig::CpuBackend::printHashrate(bool details)
|
||||||
void xmrig::CpuBackend::setJob(const Job &job)
|
void xmrig::CpuBackend::setJob(const Job &job)
|
||||||
{
|
{
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
d_ptr->workers.stop();
|
return stop();
|
||||||
d_ptr->threads.clear();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CpuConfig &cpu = d_ptr->controller->config()->cpu();
|
const CpuConfig &cpu = d_ptr->controller->config()->cpu();
|
||||||
|
@ -249,7 +245,8 @@ void xmrig::CpuBackend::start(IWorker *worker)
|
||||||
const double percent = d_ptr->status.hugePages == 0 ? 0.0 : static_cast<double>(d_ptr->status.hugePages) / d_ptr->status.pages * 100.0;
|
const double percent = d_ptr->status.hugePages == 0 ? 0.0 : static_cast<double>(d_ptr->status.hugePages) / d_ptr->status.pages * 100.0;
|
||||||
const size_t memory = d_ptr->status.ways * d_ptr->status.memory / 1024;
|
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") BLACK_BOLD(" (%" PRIu64 " ms)"),
|
LOG_INFO("%s" GREEN_BOLD(" READY") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\x1B[0m memory " CYAN_BOLD("%zu KB") BLACK_BOLD(" (%" PRIu64 " ms)"),
|
||||||
|
tag,
|
||||||
d_ptr->status.threads, d_ptr->status.ways,
|
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 ? 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,
|
||||||
|
@ -265,7 +262,12 @@ void xmrig::CpuBackend::start(IWorker *worker)
|
||||||
|
|
||||||
void xmrig::CpuBackend::stop()
|
void xmrig::CpuBackend::stop()
|
||||||
{
|
{
|
||||||
|
const uint64_t ts = Chrono::steadyMSecs();
|
||||||
|
|
||||||
d_ptr->workers.stop();
|
d_ptr->workers.stop();
|
||||||
|
d_ptr->threads.clear();
|
||||||
|
|
||||||
|
LOG_INFO("%s" YELLOW(" stopped") BLACK_BOLD(" (%" PRIu64 " ms)"), tag, Chrono::steadyMSecs() - ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,8 @@ private:
|
||||||
#define BLUE_BG_BOLD_S CSI "44;1m"
|
#define BLUE_BG_BOLD_S CSI "44;1m"
|
||||||
#define MAGENTA_BG_S CSI "45m"
|
#define MAGENTA_BG_S CSI "45m"
|
||||||
#define MAGENTA_BG_BOLD_S CSI "45;1m"
|
#define MAGENTA_BG_BOLD_S CSI "45;1m"
|
||||||
|
#define CYAN_BG_S CSI "46m"
|
||||||
|
#define CYAN_BG_BOLD_S CSI "46;1m"
|
||||||
|
|
||||||
//color wrappings
|
//color wrappings
|
||||||
#define BLACK(x) BLACK_S x CLEAR
|
#define BLACK(x) BLACK_S x CLEAR
|
||||||
|
@ -108,6 +110,8 @@ private:
|
||||||
#define BLUE_BG_BOLD(x) BLUE_BG_BOLD_S x CLEAR
|
#define BLUE_BG_BOLD(x) BLUE_BG_BOLD_S x CLEAR
|
||||||
#define MAGENTA_BG(x) MAGENTA_BG_S x CLEAR
|
#define MAGENTA_BG(x) MAGENTA_BG_S x CLEAR
|
||||||
#define MAGENTA_BG_BOLD(x) MAGENTA_BG_BOLD_S x CLEAR
|
#define MAGENTA_BG_BOLD(x) MAGENTA_BG_BOLD_S x CLEAR
|
||||||
|
#define CYAN_BG(x) CYAN_BG_S x CLEAR
|
||||||
|
#define CYAN_BG_BOLD(x) CYAN_BG_BOLD_S x CLEAR
|
||||||
|
|
||||||
|
|
||||||
#define LOG_EMERG(x, ...) xmrig::Log::print(xmrig::Log::EMERG, x, ##__VA_ARGS__)
|
#define LOG_EMERG(x, ...) xmrig::Log::print(xmrig::Log::EMERG, x, ##__VA_ARGS__)
|
||||||
|
|
|
@ -361,12 +361,18 @@ void xmrig::Miner::setEnabled(bool enabled)
|
||||||
|
|
||||||
void xmrig::Miner::setJob(const Job &job, bool donate)
|
void xmrig::Miner::setJob(const Job &job, bool donate)
|
||||||
{
|
{
|
||||||
d_ptr->algorithm = job.algorithm();
|
|
||||||
|
|
||||||
for (IBackend *backend : d_ptr->backends) {
|
for (IBackend *backend : d_ptr->backends) {
|
||||||
backend->prepare(job);
|
backend->prepare(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
if (d_ptr->algorithm.family() == Algorithm::RANDOM_X && job.algorithm().family() == Algorithm::RANDOM_X && !Rx::isReady(job)) {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
d_ptr->algorithm = job.algorithm();
|
||||||
|
|
||||||
uv_rwlock_wrlock(&d_ptr->rwlock);
|
uv_rwlock_wrlock(&d_ptr->rwlock);
|
||||||
|
|
||||||
const uint8_t index = donate ? 1 : 0;
|
const uint8_t index = donate ? 1 : 0;
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace xmrig {
|
||||||
class RxPrivate;
|
class RxPrivate;
|
||||||
|
|
||||||
|
|
||||||
static const char *tag = BLUE_BG(WHITE_BOLD_S " rx ") " ";
|
static const char *tag = BLUE_BG(WHITE_BOLD_S " rx ") " ";
|
||||||
static RxPrivate *d_ptr = nullptr;
|
static RxPrivate *d_ptr = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
@ -231,6 +231,14 @@ private:
|
||||||
} // namespace xmrig
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::Rx::isReady(const Job &job)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(d_ptr->mutex);
|
||||||
|
|
||||||
|
return d_ptr->isReady(job);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::RxDataset *xmrig::Rx::dataset(const Job &job, uint32_t nodeId)
|
xmrig::RxDataset *xmrig::Rx::dataset(const Job &job, uint32_t nodeId)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(d_ptr->mutex);
|
std::lock_guard<std::mutex> lock(d_ptr->mutex);
|
||||||
|
|
|
@ -44,6 +44,7 @@ class Job;
|
||||||
class Rx
|
class Rx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
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<size_t, size_t> hugePages();
|
static std::pair<size_t, size_t> hugePages();
|
||||||
static void destroy();
|
static void destroy();
|
||||||
|
|
Loading…
Reference in a new issue