Merge commit

This commit is contained in:
MoneroOcean 2019-07-28 11:38:00 -07:00
commit c0fec3db63
100 changed files with 33836 additions and 231 deletions

View file

@ -24,6 +24,7 @@
#include <algorithm>
#include <thread>
#include <uv.h>
@ -38,6 +39,7 @@
#include "core/Controller.h"
#include "core/Miner.h"
#include "crypto/common/Nonce.h"
#include "crypto/rx/Rx.h"
#include "rapidjson/document.h"
#include "version.h"
@ -130,16 +132,10 @@ public:
using namespace rapidjson;
auto &allocator = doc.GetAllocator();
Value cpu(kObjectType);
cpu.AddMember("brand", StringRef(Cpu::info()->brand()), allocator);
cpu.AddMember("aes", Cpu::info()->hasAES(), allocator);
cpu.AddMember("x64", Cpu::info()->isX64(), allocator);
cpu.AddMember("sockets", static_cast<uint64_t>(Cpu::info()->sockets()), allocator);
reply.AddMember("version", APP_VERSION, allocator);
reply.AddMember("kind", APP_KIND, allocator);
reply.AddMember("ua", StringRef(Platform::userAgent()), allocator);
reply.AddMember("cpu", cpu, allocator);
reply.AddMember("cpu", Cpu::toJSON(doc), allocator);
if (version == 1) {
reply.AddMember("hugepages", false, allocator);
@ -197,7 +193,7 @@ public:
total.PushBack(Hashrate::normalize(t[2]), allocator);
hashrate.AddMember("total", total, allocator);
hashrate.AddMember("highest", Hashrate::normalize(maxHashrate), allocator);
hashrate.AddMember("highest", Hashrate::normalize(maxHashrate[algorithm]), allocator);
if (version == 1) {
hashrate.AddMember("threads", threads, allocator);
@ -221,12 +217,13 @@ public:
# endif
Algorithm algorithm;
Algorithms algorithms;
bool active = false;
bool enabled = true;
Controller *controller;
double maxHashrate = 0.0;
Job job;
mutable std::map<Algorithm::Id, double> maxHashrate;
std::vector<IBackend *> backends;
String userJobId;
Timer *timer = nullptr;
@ -322,10 +319,10 @@ void xmrig::Miner::printHashrate(bool details)
}
LOG_INFO(WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("H/s") " max " CYAN_BOLD("%s H/s"),
Hashrate::format(speed[0], num, sizeof(num) / 4),
Hashrate::format(speed[1], num + 8, sizeof(num) / 4),
Hashrate::format(speed[2], num + 8 * 2, sizeof(num) / 4 ),
Hashrate::format(d_ptr->maxHashrate, num + 8 * 3, sizeof(num) / 4)
Hashrate::format(speed[0], num, sizeof(num) / 4),
Hashrate::format(speed[1], num + 8, sizeof(num) / 4),
Hashrate::format(speed[2], num + 8 * 2, sizeof(num) / 4 ),
Hashrate::format(d_ptr->maxHashrate[d_ptr->algorithm], num + 8 * 3, sizeof(num) / 4)
);
}
@ -356,6 +353,12 @@ void xmrig::Miner::setEnabled(bool enabled)
void xmrig::Miner::setJob(const Job &job, bool donate)
{
d_ptr->algorithm = job.algorithm();
for (IBackend *backend : d_ptr->backends) {
backend->prepare(job);
}
uv_rwlock_wrlock(&d_ptr->rwlock);
const uint8_t index = donate ? 1 : 0;
@ -368,6 +371,14 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
d_ptr->userJobId = job.id();
}
# ifdef XMRIG_ALGO_RANDOMX
Rx::init(job,
d_ptr->controller->config()->rx().threads(),
d_ptr->controller->config()->cpu().isHugePages(),
d_ptr->controller->config()->rx().isNUMA()
);
# endif
uv_rwlock_wrunlock(&d_ptr->rwlock);
d_ptr->handleJobChange(reset);
@ -412,7 +423,7 @@ void xmrig::Miner::onTimer(const Timer *)
}
}
d_ptr->maxHashrate = std::max(d_ptr->maxHashrate, maxHashrate);
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) {
printHashrate(false);

View file

@ -38,6 +38,17 @@
#include "rapidjson/prettywriter.h"
namespace xmrig {
static const char *kCPU = "cpu";
#ifdef XMRIG_ALGO_RANDOMX
static const char *kRandomX = "randomx";
#endif
}
xmrig::Config::Config() : BaseConfig()
{
}
@ -49,9 +60,15 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
return false;
}
m_cpu.read(reader.getValue("cpu"));
m_cpu.read(reader.getValue(kCPU));
m_benchmark.read(reader.getValue("algo-perf"));
# ifdef XMRIG_ALGO_RANDOMX
if (!m_rx.read(reader.getValue(kRandomX))) {
m_upgrade = true;
}
# endif
return true;
}
@ -69,14 +86,19 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
api.AddMember("worker-id", m_apiWorkerId.toJSON(), allocator);
doc.AddMember("api", api, allocator);
doc.AddMember("http", m_http.toJSON(doc), allocator);
doc.AddMember("autosave", isAutoSave(), allocator);
doc.AddMember("background", isBackground(), allocator);
doc.AddMember("colors", Log::colors, allocator);
doc.AddMember("cpu", m_cpu.toJSON(doc), allocator);
# ifdef XMRIG_ALGO_RANDOMX
doc.AddMember(StringRef(kRandomX), m_rx.toJSON(doc), allocator);
# endif
doc.AddMember(StringRef(kCPU), m_cpu.toJSON(doc), allocator);
doc.AddMember("algo-perf", m_benchmark.toJSON(doc), allocator);
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
doc.AddMember("http", m_http.toJSON(doc), allocator);
doc.AddMember("log-file", m_logFile.toJSON(), allocator);
doc.AddMember("pools", m_pools.toJSON(doc), allocator);
doc.AddMember("print-time", printTime(), allocator);

View file

@ -35,6 +35,11 @@
#include "rapidjson/fwd.h"
#ifdef XMRIG_ALGO_RANDOMX
# include "crypto/rx/RxConfig.h"
#endif
namespace xmrig {
@ -53,10 +58,18 @@ public:
inline const CpuConfig &cpu() const { return m_cpu; }
inline Benchmark &benchmark() { return m_benchmark; }
# ifdef XMRIG_ALGO_RANDOMX
inline const RxConfig &rx() const { return m_rx; }
# endif
private:
bool m_shouldSave = false;
CpuConfig m_cpu;
Benchmark m_benchmark;
# ifdef XMRIG_ALGO_RANDOMX
RxConfig m_rx;
# endif
};

View file

@ -36,6 +36,7 @@ static const char *kAffinity = "affinity";
static const char *kAsterisk = "*";
static const char *kCpu = "cpu";
static const char *kIntensity = "intensity";
static const char *kRandomX = "randomx";
static inline uint64_t intensity(uint64_t av)
@ -165,6 +166,14 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
return set(doc, kCpu, "asm", arg);
# endif
# ifdef XMRIG_ALGO_RANDOMX
case IConfig::RandomXInitKey: /* --randomx-init */
return set(doc, kRandomX, "init", static_cast<int64_t>(strtol(arg, nullptr, 10)));
case IConfig::RandomXNumaKey: /* --randomx-no-numa */
return set(doc, kRandomX, "numa", false);
# endif
default:
break;
}

View file

@ -37,9 +37,20 @@ R"===(
"id": null,
"worker-id": null
},
"http": {
"enabled": false,
"host": "127.0.0.1",
"port": 0,
"access-token": null,
"restricted": true
},
"autosave": true,
"background": false,
"colors": true,
"randomx": {
"init": -1,
"numa": true
},
"cpu": {
"enabled": true,
"huge-pages": true,
@ -51,13 +62,6 @@ R"===(
},
"donate-level": 5,
"donate-over-proxy": 1,
"http": {
"enabled": false,
"host": "127.0.0.1",
"port": 0,
"access-token": null,
"restricted": true
},
"log-file": null,
"pools": [
{

View file

@ -81,10 +81,10 @@ static const option options[] = {
{ "asm", 1, nullptr, IConfig::AssemblyKey },
{ "daemon", 0, nullptr, IConfig::DaemonKey },
{ "daemon-poll-interval", 1, nullptr, IConfig::DaemonPollKey },
{ "rebench-algo", 0, nullptr, IConfig::RebenchAlgoKey },
{ "bench-algo-time", 1, nullptr, IConfig::BenchAlgoTimeKey },
{ "randomx-init", 1, nullptr, IConfig::RandomXInitKey },
{ "randomx-no-numa", 0, nullptr, IConfig::RandomXNumaKey },
{ nullptr, 0, nullptr, 0 }
};

View file

@ -108,6 +108,11 @@ Options:\n\
--http-access-token=T access token for HTTP API\n\
--http-no-restricted enable full remote access to HTTP API (only if access token set)\n"
#endif
#ifdef XMRIG_ALGO_RANDOMX
"\
--randomx-init=N threads count to initialize RandomX dataset\n\
--randomx-no-numa disable NUMA support for RandomX\n"
#endif
"\
--dry-run test configuration and exit\n\
-h, --help display this help and exit\n\