Added benchmark support
This commit is contained in:
parent
9660dfc7b3
commit
e6f199e4f4
18 changed files with 309 additions and 22 deletions
|
@ -82,6 +82,7 @@ set(SOURCES
|
||||||
src/core/config/ConfigTransform.cpp
|
src/core/config/ConfigTransform.cpp
|
||||||
src/core/Controller.cpp
|
src/core/Controller.cpp
|
||||||
src/core/Miner.cpp
|
src/core/Miner.cpp
|
||||||
|
src/core/Benchmark.cpp
|
||||||
src/net/JobResults.cpp
|
src/net/JobResults.cpp
|
||||||
src/net/Network.cpp
|
src/net/Network.cpp
|
||||||
src/net/NetworkState.cpp
|
src/net/NetworkState.cpp
|
||||||
|
|
|
@ -86,7 +86,13 @@ int xmrig::App::exec()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_controller->start();
|
m_controller->pre_start();
|
||||||
|
|
||||||
|
if (m_controller->config()->benchmark().isNewBenchRun() || m_controller->config()->isRebenchAlgo()) {
|
||||||
|
m_controller->config()->benchmark().start(m_controller);
|
||||||
|
} else {
|
||||||
|
m_controller->start();
|
||||||
|
}
|
||||||
|
|
||||||
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||||
uv_loop_close(uv_default_loop());
|
uv_loop_close(uv_default_loop());
|
||||||
|
|
|
@ -131,6 +131,9 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
||||||
m_logFile = reader.getString("log-file");
|
m_logFile = reader.getString("log-file");
|
||||||
m_userAgent = reader.getString("user-agent");
|
m_userAgent = reader.getString("user-agent");
|
||||||
|
|
||||||
|
m_rebenchAlgo = reader.getBool("rebench-algo", m_rebenchAlgo);
|
||||||
|
m_benchAlgoTime = reader.getInt("bench-algo-time", m_benchAlgoTime);
|
||||||
|
|
||||||
setPrintTime(reader.getUint("print-time", 60));
|
setPrintTime(reader.getUint("print-time", 60));
|
||||||
|
|
||||||
const rapidjson::Value &api = reader.getObject("api");
|
const rapidjson::Value &api = reader.getObject("api");
|
||||||
|
|
|
@ -57,6 +57,9 @@ public:
|
||||||
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
||||||
inline uint32_t printTime() const { return m_printTime; }
|
inline uint32_t printTime() const { return m_printTime; }
|
||||||
|
|
||||||
|
inline bool isRebenchAlgo() const { return m_rebenchAlgo; }
|
||||||
|
inline int benchAlgoTime() const { return m_benchAlgoTime; }
|
||||||
|
|
||||||
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
||||||
inline const String &fileName() const override { return m_fileName; }
|
inline const String &fileName() const override { return m_fileName; }
|
||||||
inline void setFileName(const char *fileName) override { m_fileName = fileName; }
|
inline void setFileName(const char *fileName) override { m_fileName = fileName; }
|
||||||
|
@ -82,6 +85,9 @@ protected:
|
||||||
String m_userAgent;
|
String m_userAgent;
|
||||||
uint32_t m_printTime;
|
uint32_t m_printTime;
|
||||||
|
|
||||||
|
bool m_rebenchAlgo = false;
|
||||||
|
int m_benchAlgoTime = 10;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
||||||
};
|
};
|
||||||
|
|
|
@ -176,6 +176,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||||
case IConfig::HttpPort: /* --http-port */
|
case IConfig::HttpPort: /* --http-port */
|
||||||
case IConfig::DonateLevelKey: /* --donate-level */
|
case IConfig::DonateLevelKey: /* --donate-level */
|
||||||
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
||||||
|
case IConfig::BenchAlgoTimeKey: /* --bench-algo-time */
|
||||||
return transformUint64(doc, key, static_cast<uint64_t>(strtol(arg, nullptr, 10)));
|
return transformUint64(doc, key, static_cast<uint64_t>(strtol(arg, nullptr, 10)));
|
||||||
|
|
||||||
case IConfig::BackgroundKey: /* --background */
|
case IConfig::BackgroundKey: /* --background */
|
||||||
|
@ -186,6 +187,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||||
case IConfig::DryRunKey: /* --dry-run */
|
case IConfig::DryRunKey: /* --dry-run */
|
||||||
case IConfig::HttpEnabledKey: /* --http-enabled */
|
case IConfig::HttpEnabledKey: /* --http-enabled */
|
||||||
case IConfig::DaemonKey: /* --daemon */
|
case IConfig::DaemonKey: /* --daemon */
|
||||||
|
case IConfig::RebenchAlgoKey: /* --rebench-algo */
|
||||||
return transformBoolean(doc, key, true);
|
return transformBoolean(doc, key, true);
|
||||||
|
|
||||||
case IConfig::ColorKey: /* --no-color */
|
case IConfig::ColorKey: /* --no-color */
|
||||||
|
@ -233,6 +235,9 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
|
||||||
case IConfig::DryRunKey: /* --dry-run */
|
case IConfig::DryRunKey: /* --dry-run */
|
||||||
return set(doc, "dry-run", enable);
|
return set(doc, "dry-run", enable);
|
||||||
|
|
||||||
|
case IConfig::RebenchAlgoKey: /* --rebench-algo */
|
||||||
|
return set(doc, "rebench-algo", enable);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -263,6 +268,9 @@ void xmrig::BaseTransform::transformUint64(rapidjson::Document &doc, int key, ui
|
||||||
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
||||||
return add(doc, kPools, "daemon-poll-interval", arg);
|
return add(doc, kPools, "daemon-poll-interval", arg);
|
||||||
|
|
||||||
|
case IConfig::BenchAlgoTimeKey: /* --bench-algo-time */
|
||||||
|
return set(doc, "bench-algo-time", arg);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,9 @@ public:
|
||||||
NicehashKey = 1006,
|
NicehashKey = 1006,
|
||||||
PrintTimeKey = 1007,
|
PrintTimeKey = 1007,
|
||||||
|
|
||||||
|
RebenchAlgoKey = 10001,
|
||||||
|
BenchAlgoTimeKey = 10002,
|
||||||
|
|
||||||
// xmrig cpu
|
// xmrig cpu
|
||||||
AVKey = 'v',
|
AVKey = 'v',
|
||||||
CPUAffinityKey = 1020,
|
CPUAffinityKey = 1020,
|
||||||
|
|
|
@ -113,6 +113,7 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mo = false;
|
||||||
for (const rapidjson::Value &value : pools.GetArray()) {
|
for (const rapidjson::Value &value : pools.GetArray()) {
|
||||||
if (!value.IsObject()) {
|
if (!value.IsObject()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -120,10 +121,12 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
||||||
|
|
||||||
Pool pool(value);
|
Pool pool(value);
|
||||||
if (pool.isValid()) {
|
if (pool.isValid()) {
|
||||||
|
if (m_data.empty() && strstr(pool.host(), "moneroocean.stream")) mo = true;
|
||||||
m_data.push_back(std::move(pool));
|
m_data.push_back(std::move(pool));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mo) m_donateLevel = 0; else
|
||||||
setDonateLevel(reader.getInt("donate-level", kDefaultDonateLevel));
|
setDonateLevel(reader.getInt("donate-level", kDefaultDonateLevel));
|
||||||
setProxyDonate(reader.getInt("donate-over-proxy", PROXY_DONATE_AUTO));
|
setProxyDonate(reader.getInt("donate-over-proxy", PROXY_DONATE_AUTO));
|
||||||
setRetries(reader.getInt("retries"));
|
setRetries(reader.getInt("retries"));
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
"worker-id": null
|
"worker-id": null
|
||||||
},
|
},
|
||||||
"autosave": true,
|
"autosave": true,
|
||||||
|
"rebench-algo": false,
|
||||||
|
"bench-algo-time": 10,
|
||||||
"background": false,
|
"background": false,
|
||||||
"colors": true,
|
"colors": true,
|
||||||
"cpu": {
|
"cpu": {
|
||||||
|
@ -15,7 +17,7 @@
|
||||||
"cn/0": false,
|
"cn/0": false,
|
||||||
"cn-lite/0": false
|
"cn-lite/0": false
|
||||||
},
|
},
|
||||||
"donate-level": 5,
|
"donate-level": 1,
|
||||||
"donate-over-proxy": 1,
|
"donate-over-proxy": 1,
|
||||||
"http": {
|
"http": {
|
||||||
"enabled": false,
|
"enabled": false,
|
||||||
|
@ -41,7 +43,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"print-time": 60,
|
"print-time": 60,
|
||||||
"retries": 5,
|
"retries": 0,
|
||||||
"retry-pause": 5,
|
"retry-pause": 5,
|
||||||
"syslog": false,
|
"syslog": false,
|
||||||
"user-agent": null,
|
"user-agent": null,
|
||||||
|
|
161
src/core/Benchmark.cpp
Normal file
161
src/core/Benchmark.cpp
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "core/Benchmark.h"
|
||||||
|
#include "core/Controller.h"
|
||||||
|
#include "core/config/Config.h"
|
||||||
|
#include "core/Miner.h"
|
||||||
|
#include "base/io/log/Log.h"
|
||||||
|
#include "base/net/stratum/Job.h"
|
||||||
|
#include "net/JobResult.h"
|
||||||
|
#include "net/JobResults.h"
|
||||||
|
#include "net/Network.h"
|
||||||
|
#include "rapidjson/document.h"
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
// start performance measurements from the first bench_algo
|
||||||
|
void Benchmark::start(Controller* controller) {
|
||||||
|
m_controller = controller;
|
||||||
|
JobResults::setListener(this); // register benchmark as job result listener to compute hashrates there
|
||||||
|
// write text before first benchmark round
|
||||||
|
LOG_ALERT(">>>>> STARTING ALGO PERFORMANCE CALIBRATION (with %i seconds round)", m_controller->config()->benchAlgoTime());
|
||||||
|
// start benchmarking from first PerfAlgo in the list
|
||||||
|
start(xmrig::Benchmark::MIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// end of benchmarks, switch to jobs from the pool (network), fill algo_perf
|
||||||
|
void Benchmark::finish() {
|
||||||
|
for (Algorithm::Id algo = static_cast<Algorithm::Id>(0); algo != Algorithm::MAX; algo = static_cast<Algorithm::Id>(algo + 1)) {
|
||||||
|
algo_perf[algo] = get_algo_perf(algo);
|
||||||
|
}
|
||||||
|
m_bench_algo = BenchAlgo::INVALID;
|
||||||
|
m_controller->miner()->pause(); // do not compute anything before job from the pool
|
||||||
|
JobResults::setListener(m_controller->network());
|
||||||
|
m_controller->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
rapidjson::Value Benchmark::toJSON(rapidjson::Document &doc) const
|
||||||
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
|
Value obj(kObjectType);
|
||||||
|
|
||||||
|
for (const auto &a : m_controller->miner()->algorithms()) {
|
||||||
|
obj.AddMember(StringRef(a.shortName()), algo_perf[a.id()], allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Benchmark::read(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
for (Algorithm::Id algo = static_cast<Algorithm::Id>(0); algo != Algorithm::MAX; algo = static_cast<Algorithm::Id>(algo + 1)) {
|
||||||
|
algo_perf[algo] = 0.0f;
|
||||||
|
}
|
||||||
|
if (value.IsObject()) {
|
||||||
|
for (auto &member : value.GetObject()) {
|
||||||
|
const Algorithm algo(member.name.GetString());
|
||||||
|
if (!algo.isValid()) {
|
||||||
|
LOG_ALERT("Ignoring wrong algo-perf name %s", member.name.GetString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!member.value.IsFloat()) {
|
||||||
|
LOG_ALERT("Ignoring wrong value for %s algo-perf", member.name.GetString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
algo_perf[algo.id()] = member.value.GetFloat();
|
||||||
|
m_isNewBenchRun = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float Benchmark::get_algo_perf(Algorithm::Id algo) const {
|
||||||
|
switch (algo) {
|
||||||
|
case Algorithm::CN_0: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||||
|
case Algorithm::CN_1: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||||
|
case Algorithm::CN_2: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||||
|
case Algorithm::CN_R: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||||
|
case Algorithm::CN_WOW: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||||
|
case Algorithm::CN_FAST: return m_bench_algo_perf[BenchAlgo::CN_R] * 2;
|
||||||
|
case Algorithm::CN_HALF: return m_bench_algo_perf[BenchAlgo::CN_R] * 2;
|
||||||
|
case Algorithm::CN_XAO: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||||
|
case Algorithm::CN_RTO: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||||
|
case Algorithm::CN_RWZ: return m_bench_algo_perf[BenchAlgo::CN_R] / 3 * 4;
|
||||||
|
case Algorithm::CN_ZLS: return m_bench_algo_perf[BenchAlgo::CN_R] / 3 * 4;
|
||||||
|
case Algorithm::CN_DOUBLE: return m_bench_algo_perf[BenchAlgo::CN_R] / 2;
|
||||||
|
case Algorithm::CN_GPU: return m_bench_algo_perf[BenchAlgo::CN_GPU];
|
||||||
|
case Algorithm::CN_LITE_0: return m_bench_algo_perf[BenchAlgo::CN_LITE_1];
|
||||||
|
case Algorithm::CN_LITE_1: return m_bench_algo_perf[BenchAlgo::CN_LITE_1];
|
||||||
|
case Algorithm::CN_HEAVY_0: return m_bench_algo_perf[BenchAlgo::CN_HEAVY_TUBE];
|
||||||
|
case Algorithm::CN_HEAVY_TUBE: return m_bench_algo_perf[BenchAlgo::CN_HEAVY_TUBE];
|
||||||
|
case Algorithm::CN_HEAVY_XHV: return m_bench_algo_perf[BenchAlgo::CN_HEAVY_TUBE];
|
||||||
|
case Algorithm::CN_PICO_0: return m_bench_algo_perf[BenchAlgo::CN_PICO_0];
|
||||||
|
case Algorithm::RX_0: return m_bench_algo_perf[BenchAlgo::RX_0];
|
||||||
|
case Algorithm::RX_WOW: return m_bench_algo_perf[BenchAlgo::RX_WOW];
|
||||||
|
case Algorithm::RX_LOKI: return m_bench_algo_perf[BenchAlgo::RX_0];
|
||||||
|
default: return 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// start performance measurements for specified perf bench_algo
|
||||||
|
void Benchmark::start(const BenchAlgo bench_algo) {
|
||||||
|
// prepare test job for benchmark runs ("benchmark" client id is to make sure we can detect benchmark jobs)
|
||||||
|
Job job(false, Algorithm(ba2a[bench_algo]), "benchmark");
|
||||||
|
job.setId(Algorithm(ba2a[bench_algo]).shortName()); // need to set different id so that workers will see job change
|
||||||
|
// 99 here to trigger all future bench_algo versions for auto veriant detection based on block version
|
||||||
|
job.setBlob("9905A0DBD6BF05CF16E503F3A66F78007CBF34144332ECBFC22ED95C8700383B309ACE1923A0964B00000008BA939A62724C0D7581FCE5761E9D8A0E6A1C3F924FDD8493D1115649C05EB601");
|
||||||
|
job.setTarget("FFFFFFFFFFFFFF20"); // set difficulty to 8 cause onJobResult after every 8-th computed hash
|
||||||
|
job.setSeedHash("0000000000000000000000000000000000000000000000000000000000000001");
|
||||||
|
m_bench_algo = bench_algo; // current perf bench_algo
|
||||||
|
m_hash_count = 0; // number of hashes calculated for current perf bench_algo
|
||||||
|
m_time_start = 0; // init time of measurements start (in ms) during the first onJobResult
|
||||||
|
m_controller->miner()->setJob(job, false); // set job for workers to compute
|
||||||
|
}
|
||||||
|
|
||||||
|
void Benchmark::onJobResult(const JobResult& result) {
|
||||||
|
if (result.clientId != String("benchmark")) { // switch to network pool jobs
|
||||||
|
JobResults::setListener(m_controller->network());
|
||||||
|
static_cast<IJobResultListener*>(m_controller->network())->onJobResult(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ignore benchmark results for other perf bench_algo
|
||||||
|
if (m_bench_algo == BenchAlgo::INVALID || result.jobId != String(Algorithm(ba2a[m_bench_algo]).shortName())) return;
|
||||||
|
++ m_hash_count;
|
||||||
|
const uint64_t now = get_now();
|
||||||
|
if (!m_time_start) m_time_start = now; // time of measurements start (in ms)
|
||||||
|
else if (now - m_time_start > static_cast<unsigned>(m_controller->config()->benchAlgoTime()*1000)) { // end of benchmark round for m_bench_algo
|
||||||
|
const float hashrate = static_cast<float>(m_hash_count) * result.diff / (now - m_time_start) * 1000.0f;
|
||||||
|
m_bench_algo_perf[m_bench_algo] = hashrate; // store hashrate result
|
||||||
|
LOG_ALERT(" ===> %s hasrate: %f", Algorithm(ba2a[m_bench_algo]).shortName(), hashrate);
|
||||||
|
const BenchAlgo next_bench_algo = static_cast<BenchAlgo>(m_bench_algo + 1); // compute next perf bench_algo to benchmark
|
||||||
|
if (next_bench_algo != BenchAlgo::MAX) {
|
||||||
|
start(next_bench_algo);
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Benchmark::get_now() const { // get current time in ms
|
||||||
|
using namespace std::chrono;
|
||||||
|
return time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace xmrig
|
81
src/core/Benchmark.h
Normal file
81
src/core/Benchmark.h
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2018-2019 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "net/interfaces/IJobResultListener.h"
|
||||||
|
#include "crypto/common/Algorithm.h"
|
||||||
|
#include "rapidjson/fwd.h"
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
class Controller;
|
||||||
|
class Miner;
|
||||||
|
|
||||||
|
class Benchmark : public IJobResultListener {
|
||||||
|
|
||||||
|
enum BenchAlgo : int {
|
||||||
|
CN_R, // "cn/r" CryptoNightR (Monero's variant 4).
|
||||||
|
CN_GPU, // "cn/gpu" CryptoNight-GPU (Ryo).
|
||||||
|
CN_LITE_1, // "cn-lite/1" CryptoNight-Lite variant 1.
|
||||||
|
CN_HEAVY_TUBE, // "cn-heavy/tube" CryptoNight-Heavy (modified, TUBE only).
|
||||||
|
CN_PICO_0, // "cn-pico" CryptoNight Turtle (TRTL)
|
||||||
|
RX_0, // "rx/0" RandomX (reference configuration).
|
||||||
|
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||||
|
MAX,
|
||||||
|
MIN = 0,
|
||||||
|
INVALID = -1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const Algorithm::Id ba2a[BenchAlgo::MAX] = {
|
||||||
|
Algorithm::CN_R,
|
||||||
|
Algorithm::CN_GPU,
|
||||||
|
Algorithm::CN_LITE_1,
|
||||||
|
Algorithm::CN_HEAVY_TUBE,
|
||||||
|
Algorithm::CN_PICO_0,
|
||||||
|
Algorithm::RX_0,
|
||||||
|
Algorithm::RX_WOW,
|
||||||
|
};
|
||||||
|
|
||||||
|
float m_bench_algo_perf[BenchAlgo::MAX];
|
||||||
|
|
||||||
|
Controller* m_controller; // to get access to config and network
|
||||||
|
bool m_isNewBenchRun;
|
||||||
|
Benchmark::BenchAlgo m_bench_algo; // current perf algo we benchmark
|
||||||
|
uint64_t m_hash_count; // number of hashes calculated for current perf algo
|
||||||
|
uint64_t m_time_start; // time of measurements start for current perf algo (in ms)
|
||||||
|
|
||||||
|
uint64_t get_now() const; // get current time in ms
|
||||||
|
float get_algo_perf(Algorithm::Id algo) const; // get algo perf based on m_bench_algo_perf
|
||||||
|
void start(const Benchmark::BenchAlgo); // start benchmark for specified perf algo
|
||||||
|
void finish(); // end of benchmarks, switch to jobs from the pool (network), fill algo_perf
|
||||||
|
void onJobResult(const JobResult&) override; // onJobResult is called after each computed benchmark hash
|
||||||
|
|
||||||
|
public:
|
||||||
|
Benchmark() : m_controller(nullptr), m_isNewBenchRun(true) {}
|
||||||
|
virtual ~Benchmark() {}
|
||||||
|
|
||||||
|
void start(Controller* controller); // start benchmarks
|
||||||
|
|
||||||
|
bool isNewBenchRun() const { return m_isNewBenchRun; }
|
||||||
|
float algo_perf[Algorithm::MAX];
|
||||||
|
|
||||||
|
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||||
|
void read(const rapidjson::Value &value);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace xmrig
|
|
@ -63,13 +63,15 @@ int xmrig::Controller::init()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xmrig::Controller::pre_start()
|
||||||
|
{
|
||||||
|
m_miner = new Miner(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Controller::start()
|
void xmrig::Controller::start()
|
||||||
{
|
{
|
||||||
Base::start();
|
Base::start();
|
||||||
|
|
||||||
m_miner = new Miner(this);
|
|
||||||
|
|
||||||
network()->connect();
|
network()->connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
|
|
||||||
bool isReady() const override;
|
bool isReady() const override;
|
||||||
int init() override;
|
int init() override;
|
||||||
|
void pre_start();
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cpu.read(reader.getValue("cpu"));
|
m_cpu.read(reader.getValue("cpu"));
|
||||||
|
m_benchmark.read(reader.getValue("algo-perf"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +73,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
doc.AddMember("background", isBackground(), allocator);
|
doc.AddMember("background", isBackground(), allocator);
|
||||||
doc.AddMember("colors", Log::colors, allocator);
|
doc.AddMember("colors", Log::colors, allocator);
|
||||||
doc.AddMember("cpu", m_cpu.toJSON(doc), allocator);
|
doc.AddMember("cpu", 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-level", m_pools.donateLevel(), allocator);
|
||||||
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
|
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
|
||||||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
||||||
|
@ -83,4 +85,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
doc.AddMember("syslog", isSyslog(), allocator);
|
doc.AddMember("syslog", isSyslog(), allocator);
|
||||||
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator);
|
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator);
|
||||||
doc.AddMember("watch", m_watch, allocator);
|
doc.AddMember("watch", m_watch, allocator);
|
||||||
|
|
||||||
|
doc.AddMember("rebench-algo", isRebenchAlgo(), allocator);
|
||||||
|
doc.AddMember("bench-algo-time", benchAlgoTime(), allocator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "backend/cpu/CpuConfig.h"
|
#include "backend/cpu/CpuConfig.h"
|
||||||
#include "base/kernel/config/BaseConfig.h"
|
#include "base/kernel/config/BaseConfig.h"
|
||||||
|
#include "core/Benchmark.h"
|
||||||
#include "rapidjson/fwd.h"
|
#include "rapidjson/fwd.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,12 +49,14 @@ public:
|
||||||
bool read(const IJsonReader &reader, const char *fileName) override;
|
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||||
void getJSON(rapidjson::Document &doc) const override;
|
void getJSON(rapidjson::Document &doc) const override;
|
||||||
|
|
||||||
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade || m_cpu.isShouldSave()) && isAutoSave(); }
|
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade || m_cpu.isShouldSave() || m_benchmark.isNewBenchRun()) && isAutoSave(); }
|
||||||
inline const CpuConfig &cpu() const { return m_cpu; }
|
inline const CpuConfig &cpu() const { return m_cpu; }
|
||||||
|
inline Benchmark &benchmark() { return m_benchmark; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_shouldSave = false;
|
bool m_shouldSave = false;
|
||||||
CpuConfig m_cpu;
|
CpuConfig m_cpu;
|
||||||
|
Benchmark m_benchmark;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,10 @@ static const option options[] = {
|
||||||
{ "asm", 1, nullptr, IConfig::AssemblyKey },
|
{ "asm", 1, nullptr, IConfig::AssemblyKey },
|
||||||
{ "daemon", 0, nullptr, IConfig::DaemonKey },
|
{ "daemon", 0, nullptr, IConfig::DaemonKey },
|
||||||
{ "daemon-poll-interval", 1, nullptr, IConfig::DaemonPollKey },
|
{ "daemon-poll-interval", 1, nullptr, IConfig::DaemonPollKey },
|
||||||
|
|
||||||
|
{ "rebench-algo", 0, nullptr, IConfig::RebenchAlgoKey },
|
||||||
|
{ "bench-algo-time", 1, nullptr, IConfig::BenchAlgoTimeKey },
|
||||||
|
|
||||||
{ nullptr, 0, nullptr, 0 }
|
{ nullptr, 0, nullptr, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,14 @@ void xmrig::Network::onLogin(IStrategy *, IClient *client, rapidjson::Document &
|
||||||
}
|
}
|
||||||
|
|
||||||
params.AddMember("algo", algo, allocator);
|
params.AddMember("algo", algo, allocator);
|
||||||
|
|
||||||
|
Value algo_perf(kObjectType);
|
||||||
|
|
||||||
|
for (const auto &a : algorithms) {
|
||||||
|
algo_perf.AddMember(StringRef(a.shortName()), m_controller->config()->benchmark().algo_perf[a.id()], allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
params.AddMember("algo-perf", algo_perf, allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,11 +49,6 @@ namespace xmrig {
|
||||||
static inline double randomf(double min, double max) { return (max - min) * (((static_cast<double>(rand())) / static_cast<double>(RAND_MAX))) + min; }
|
static inline double randomf(double min, double max) { return (max - min) * (((static_cast<double>(rand())) / static_cast<double>(RAND_MAX))) + min; }
|
||||||
static inline uint64_t random(uint64_t base, double min, double max) { return static_cast<uint64_t>(base * randomf(min, max)); }
|
static inline uint64_t random(uint64_t base, double min, double max) { return static_cast<uint64_t>(base * randomf(min, max)); }
|
||||||
|
|
||||||
static const char *kDonateHost = "donate.v2.xmrig.com";
|
|
||||||
#ifdef XMRIG_FEATURE_TLS
|
|
||||||
static const char *kDonateHostTls = "donate.ssl.xmrig.com";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} /* namespace xmrig */
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,16 +65,11 @@ xmrig::DonateStrategy::DonateStrategy(Controller *controller, IStrategyListener
|
||||||
m_now(0),
|
m_now(0),
|
||||||
m_timestamp(0)
|
m_timestamp(0)
|
||||||
{
|
{
|
||||||
uint8_t hash[200];
|
static char donate_user[] = "44qJYxdbuqSKarYnDSXB6KLbsH4yR65vpJe3ELLDii9i4ZgKpgQXZYR4AMJxBJbfbKZGWUxZU42QyZSsP4AyZZMbJBCrWr1";
|
||||||
|
# ifndef XMRIG_FEATURE_TLS
|
||||||
const String &user = controller->config()->pools().data().front().user();
|
m_pools.push_back(Pool("xmrig.moneroocean.stream", 20001, donate_user, nullptr, 0, true, true));
|
||||||
keccak(reinterpret_cast<const uint8_t *>(user.data()), user.size(), hash);
|
|
||||||
Buffer::toHex(hash, 32, m_userId);
|
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
|
||||||
m_pools.push_back(Pool(kDonateHostTls, 443, m_userId, nullptr, 0, true, true));
|
|
||||||
# endif
|
# endif
|
||||||
m_pools.push_back(Pool(kDonateHost, 3333, m_userId, nullptr, 0, true));
|
m_pools.push_back(Pool("xmrig.moneroocean.stream", 10001, donate_user, nullptr, 0, true));
|
||||||
|
|
||||||
if (m_pools.size() > 1) {
|
if (m_pools.size() > 1) {
|
||||||
m_strategy = new FailoverStrategy(m_pools, 1, 2, this, true);
|
m_strategy = new FailoverStrategy(m_pools, 1, 2, this, true);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#define APP_ID "xmrig"
|
#define APP_ID "xmrig"
|
||||||
#define APP_NAME "XMRig"
|
#define APP_NAME "XMRig"
|
||||||
#define APP_DESC "XMRig CPU miner"
|
#define APP_DESC "XMRig CPU miner"
|
||||||
#define APP_VERSION "2.99.0-evo"
|
#define APP_VERSION "2.99.0-evo-mo1"
|
||||||
#define APP_DOMAIN "xmrig.com"
|
#define APP_DOMAIN "xmrig.com"
|
||||||
#define APP_SITE "www.xmrig.com"
|
#define APP_SITE "www.xmrig.com"
|
||||||
#define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com"
|
#define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue