Added BenchConfig class.
This commit is contained in:
parent
a3daaf09f5
commit
027a6f8ae2
19 changed files with 321 additions and 127 deletions
|
@ -237,8 +237,15 @@ endif()
|
||||||
if (WITH_RANDOMX AND WITH_BENCHMARK)
|
if (WITH_RANDOMX AND WITH_BENCHMARK)
|
||||||
add_definitions(/DXMRIG_FEATURE_BENCHMARK)
|
add_definitions(/DXMRIG_FEATURE_BENCHMARK)
|
||||||
|
|
||||||
list(APPEND HEADERS_BASE src/base/net/stratum/NullClient.h)
|
list(APPEND HEADERS_BASE
|
||||||
list(APPEND SOURCES_BASE src/base/net/stratum/NullClient.cpp)
|
src/base/net/stratum/benchmark/BenchClient.h
|
||||||
|
src/base/net/stratum/benchmark/BenchConfig.h
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND SOURCES_BASE
|
||||||
|
src/base/net/stratum/benchmark/BenchClient.cpp
|
||||||
|
src/base/net/stratum/benchmark/BenchConfig.cpp
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
remove_definitions(/DXMRIG_FEATURE_BENCHMARK)
|
remove_definitions(/DXMRIG_FEATURE_BENCHMARK)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -153,7 +153,6 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||||
|
|
||||||
case IConfig::UrlKey: /* --url */
|
case IConfig::UrlKey: /* --url */
|
||||||
case IConfig::StressKey: /* --stress */
|
case IConfig::StressKey: /* --stress */
|
||||||
case IConfig::BenchKey: /* --bench */
|
|
||||||
{
|
{
|
||||||
if (!doc.HasMember(Pools::kPools)) {
|
if (!doc.HasMember(Pools::kPools)) {
|
||||||
doc.AddMember(rapidjson::StringRef(Pools::kPools), rapidjson::kArrayType, doc.GetAllocator());
|
doc.AddMember(rapidjson::StringRef(Pools::kPools), rapidjson::kArrayType, doc.GetAllocator());
|
||||||
|
@ -166,7 +165,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
if (key != IConfig::UrlKey) {
|
if (key != IConfig::UrlKey) {
|
||||||
set(doc, array[array.Size() - 1], Pool::kUrl, (key == IConfig::BenchKey) ? "benchmark" :
|
set(doc, array[array.Size() - 1], Pool::kUrl,
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
"stratum+ssl://randomx.xmrig.com:443"
|
"stratum+ssl://randomx.xmrig.com:443"
|
||||||
# else
|
# else
|
||||||
|
|
|
@ -79,6 +79,10 @@ public:
|
||||||
PauseOnBatteryKey = 1041,
|
PauseOnBatteryKey = 1041,
|
||||||
StressKey = 1042,
|
StressKey = 1042,
|
||||||
BenchKey = 1043,
|
BenchKey = 1043,
|
||||||
|
BenchSubmitKey = 1044,
|
||||||
|
BenchVerifyKey = 1045,
|
||||||
|
BenchSeedKey = 1046,
|
||||||
|
BenchHashKey = 1047,
|
||||||
|
|
||||||
// xmrig common
|
// xmrig common
|
||||||
CPUPriorityKey = 1021,
|
CPUPriorityKey = 1021,
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
inline uint32_t backend() const { return m_backend; }
|
inline uint32_t backend() const { return m_backend; }
|
||||||
inline uint64_t diff() const { return m_diff; }
|
inline uint64_t diff() const { return m_diff; }
|
||||||
inline uint64_t height() const { return m_height; }
|
inline uint64_t height() const { return m_height; }
|
||||||
inline uint64_t nonceMask() const { return isNicehash() ? 0xFFFFFFULL : (nonceSize() == sizeof(uint64_t) ? (-1ull >> (extraNonce().size() * 4)): 0xFFFFFFFFULL); }
|
inline uint64_t nonceMask() const { return isNicehash() ? 0xFFFFFFULL : (nonceSize() == sizeof(uint64_t) ? (-1ULL >> (extraNonce().size() * 4)): 0xFFFFFFFFULL); }
|
||||||
inline uint64_t target() const { return m_target; }
|
inline uint64_t target() const { return m_target; }
|
||||||
inline uint8_t *blob() { return m_blob; }
|
inline uint8_t *blob() { return m_blob; }
|
||||||
inline uint8_t fixedByte() const { return *(m_blob + 42); }
|
inline uint8_t fixedByte() const { return *(m_blob + 42); }
|
||||||
|
|
|
@ -51,7 +51,8 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
# include "base/net/stratum/NullClient.h"
|
# include "base/net/stratum/benchmark/BenchClient.h"
|
||||||
|
# include "base/net/stratum/benchmark/BenchConfig.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,10 +85,6 @@ const char *Pool::kUrl = "url";
|
||||||
const char *Pool::kUser = "user";
|
const char *Pool::kUser = "user";
|
||||||
const char *Pool::kNicehashHost = "nicehash.com";
|
const char *Pool::kNicehashHost = "nicehash.com";
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
const char *Pool::kBenchmark = "benchmark";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,14 +136,6 @@ xmrig::Pool::Pool(const rapidjson::Value &object) :
|
||||||
|
|
||||||
setKeepAlive(Json::getValue(object, kKeepalive));
|
setKeepAlive(Json::getValue(object, kKeepalive));
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
if (setBenchSize(Json::getString(object, kBenchmark, nullptr))) {
|
|
||||||
m_mode = MODE_BENCHMARK;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (m_daemon.isValid()) {
|
if (m_daemon.isValid()) {
|
||||||
m_mode = MODE_SELF_SELECT;
|
m_mode = MODE_SELF_SELECT;
|
||||||
}
|
}
|
||||||
|
@ -156,6 +145,31 @@ xmrig::Pool::Pool(const rapidjson::Value &object) :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
xmrig::Pool::Pool(const std::shared_ptr<BenchConfig> &benchmark) :
|
||||||
|
m_mode(MODE_BENCHMARK),
|
||||||
|
m_flags(1 << FLAG_ENABLED),
|
||||||
|
m_url(BenchConfig::kBenchmark),
|
||||||
|
m_benchmark(benchmark)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::BenchConfig *xmrig::Pool::benchmark() const
|
||||||
|
{
|
||||||
|
assert(m_mode == MODE_BENCHMARK && m_benchmark);
|
||||||
|
|
||||||
|
return m_benchmark.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t xmrig::Pool::benchSize() const
|
||||||
|
{
|
||||||
|
return benchmark()->size();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Pool::isEnabled() const
|
bool xmrig::Pool::isEnabled() const
|
||||||
{
|
{
|
||||||
# ifndef XMRIG_FEATURE_TLS
|
# ifndef XMRIG_FEATURE_TLS
|
||||||
|
@ -233,7 +247,7 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con
|
||||||
# endif
|
# endif
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
else if (m_mode == MODE_BENCHMARK) {
|
else if (m_mode == MODE_BENCHMARK) {
|
||||||
client = new NullClient(listener);
|
client = new BenchClient(m_benchmark, listener);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -337,23 +351,3 @@ void xmrig::Pool::setKeepAlive(const rapidjson::Value &value)
|
||||||
setKeepAlive(value.GetBool());
|
setKeepAlive(value.GetBool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
bool xmrig::Pool::setBenchSize(const char *benchmark)
|
|
||||||
{
|
|
||||||
if (!benchmark) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto size = strtoul(benchmark, nullptr, 10);
|
|
||||||
if (size < 1 || size > 10) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string s = std::to_string(size) + "M";
|
|
||||||
m_benchSize = strcasecmp(benchmark, s.c_str()) == 0 ? size * 1000000 : 0;
|
|
||||||
|
|
||||||
return m_benchSize > 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
#include "3rdparty/rapidjson/fwd.h"
|
#include "3rdparty/rapidjson/fwd.h"
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class BenchConfig;
|
||||||
class IClient;
|
class IClient;
|
||||||
class IClientListener;
|
class IClientListener;
|
||||||
|
|
||||||
|
@ -76,10 +78,6 @@ public:
|
||||||
static const char *kUser;
|
static const char *kUser;
|
||||||
static const char *kNicehashHost;
|
static const char *kNicehashHost;
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
static const char *kBenchmark;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
constexpr static int kKeepAliveTimeout = 60;
|
constexpr static int kKeepAliveTimeout = 60;
|
||||||
constexpr static uint16_t kDefaultPort = 3333;
|
constexpr static uint16_t kDefaultPort = 3333;
|
||||||
constexpr static uint64_t kDefaultPollInterval = 1000;
|
constexpr static uint64_t kDefaultPollInterval = 1000;
|
||||||
|
@ -89,6 +87,13 @@ public:
|
||||||
Pool(const char *url);
|
Pool(const char *url);
|
||||||
Pool(const rapidjson::Value &object);
|
Pool(const rapidjson::Value &object);
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
Pool(const std::shared_ptr<BenchConfig> &benchmark);
|
||||||
|
|
||||||
|
BenchConfig *benchmark() const;
|
||||||
|
uint32_t benchSize() const;
|
||||||
|
# endif
|
||||||
|
|
||||||
inline bool isNicehash() const { return m_flags.test(FLAG_NICEHASH); }
|
inline bool isNicehash() const { return m_flags.test(FLAG_NICEHASH); }
|
||||||
inline bool isTLS() const { return m_flags.test(FLAG_TLS) || m_url.isTLS(); }
|
inline bool isTLS() const { return m_flags.test(FLAG_TLS) || m_url.isTLS(); }
|
||||||
inline bool isValid() const { return m_url.isValid(); }
|
inline bool isValid() const { return m_url.isValid(); }
|
||||||
|
@ -112,10 +117,6 @@ public:
|
||||||
inline void setRigId(const String &rigId) { m_rigId = rigId; }
|
inline void setRigId(const String &rigId) { m_rigId = rigId; }
|
||||||
inline void setUser(const String &user) { m_user = user; }
|
inline void setUser(const String &user) { m_user = user; }
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
inline uint32_t benchSize() const { return m_benchSize; }
|
|
||||||
# endif
|
|
||||||
|
|
||||||
inline bool operator!=(const Pool &other) const { return !isEqual(other); }
|
inline bool operator!=(const Pool &other) const { return !isEqual(other); }
|
||||||
inline bool operator==(const Pool &other) const { return isEqual(other); }
|
inline bool operator==(const Pool &other) const { return isEqual(other); }
|
||||||
|
|
||||||
|
@ -157,9 +158,7 @@ private:
|
||||||
Url m_url;
|
Url m_url;
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
bool setBenchSize(const char *benchmark);
|
std::shared_ptr<BenchConfig> m_benchmark;
|
||||||
|
|
||||||
uint32_t m_benchSize = 0;
|
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@
|
||||||
#include "donate.h"
|
#include "donate.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
# include "base/net/stratum/benchmark/BenchConfig.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,6 +123,15 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
||||||
{
|
{
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
m_benchmark = std::shared_ptr<BenchConfig>(BenchConfig::create(reader.getObject(BenchConfig::kBenchmark)));
|
||||||
|
if (m_benchmark) {
|
||||||
|
m_data.emplace_back(m_benchmark);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
const rapidjson::Value &pools = reader.getArray(kPools);
|
const rapidjson::Value &pools = reader.getArray(kPools);
|
||||||
if (!pools.IsArray()) {
|
if (!pools.IsArray()) {
|
||||||
return;
|
return;
|
||||||
|
@ -144,12 +158,10 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
||||||
uint32_t xmrig::Pools::benchSize() const
|
uint32_t xmrig::Pools::benchSize() const
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
if (m_data.size() == 1 && m_data.front().mode() == Pool::MODE_BENCHMARK) {
|
return m_benchmark ? m_benchmark->size() : 0;
|
||||||
return m_data.front().benchSize();
|
# else
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,10 @@ private:
|
||||||
int m_retryPause = 5;
|
int m_retryPause = 5;
|
||||||
ProxyDonate m_proxyDonate = PROXY_DONATE_AUTO;
|
ProxyDonate m_proxyDonate = PROXY_DONATE_AUTO;
|
||||||
std::vector<Pool> m_data;
|
std::vector<Pool> m_data;
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
std::shared_ptr<BenchConfig> m_benchmark;
|
||||||
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,15 +16,16 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "base/net/stratum/NullClient.h"
|
#include "base/net/stratum/benchmark/BenchClient.h"
|
||||||
#include "3rdparty/rapidjson/document.h"
|
#include "3rdparty/rapidjson/document.h"
|
||||||
#include "base/kernel/interfaces/IClientListener.h"
|
#include "base/kernel/interfaces/IClientListener.h"
|
||||||
|
#include "base/net/stratum/benchmark/BenchConfig.h"
|
||||||
|
|
||||||
|
|
||||||
xmrig::NullClient::NullClient(IClientListener* listener) :
|
xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, IClientListener* listener) :
|
||||||
m_listener(listener)
|
m_listener(listener)
|
||||||
{
|
{
|
||||||
m_job.setAlgorithm(Algorithm::RX_0);
|
m_job.setAlgorithm(benchmark->algorithm());
|
||||||
|
|
||||||
std::vector<char> blob(112 * 2 + 1, '0');
|
std::vector<char> blob(112 * 2 + 1, '0');
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ xmrig::NullClient::NullClient(IClientListener* listener) :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::NullClient::connect()
|
void xmrig::BenchClient::connect()
|
||||||
{
|
{
|
||||||
m_listener->onLoginSuccess(this);
|
m_listener->onLoginSuccess(this);
|
||||||
|
|
||||||
|
@ -50,13 +51,7 @@ void xmrig::NullClient::connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::NullClient::setPool(const Pool& pool)
|
void xmrig::BenchClient::setPool(const Pool &pool)
|
||||||
{
|
{
|
||||||
m_pool = pool;
|
m_pool = pool;
|
||||||
|
|
||||||
if (!m_pool.algorithm().isValid()) {
|
|
||||||
m_pool.setAlgo(Algorithm::RX_0);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_job.setAlgorithm(m_pool.algorithm().id());
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef XMRIG_NULLCLIENT_H
|
#ifndef XMRIG_BENCHCLIENT_H
|
||||||
#define XMRIG_NULLCLIENT_H
|
#define XMRIG_BENCHCLIENT_H
|
||||||
|
|
||||||
|
|
||||||
#include "base/net/stratum/Client.h"
|
#include "base/net/stratum/Client.h"
|
||||||
|
@ -26,16 +26,16 @@
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
class NullClient : public IClient
|
class BenchClient : public IClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(NullClient)
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(BenchClient)
|
||||||
|
|
||||||
NullClient(IClientListener* listener);
|
BenchClient(const std::shared_ptr<BenchConfig> &benchmark, IClientListener* listener);
|
||||||
~NullClient() override = default;
|
~BenchClient() override = default;
|
||||||
|
|
||||||
inline bool disconnect() override { return true; }
|
inline bool disconnect() override { return true; }
|
||||||
inline bool hasExtension(Extension extension) const noexcept override { return false; }
|
inline bool hasExtension(Extension) const noexcept override { return false; }
|
||||||
inline bool isEnabled() const override { return true; }
|
inline bool isEnabled() const override { return true; }
|
||||||
inline bool isTLS() const override { return false; }
|
inline bool isTLS() const override { return false; }
|
||||||
inline const char *mode() const override { return "benchmark"; }
|
inline const char *mode() const override { return "benchmark"; }
|
||||||
|
@ -46,27 +46,28 @@ public:
|
||||||
inline const Pool &pool() const override { return m_pool; }
|
inline const Pool &pool() const override { return m_pool; }
|
||||||
inline const String &ip() const override { return m_ip; }
|
inline const String &ip() const override { return m_ip; }
|
||||||
inline int id() const override { return 0; }
|
inline int id() const override { return 0; }
|
||||||
inline int64_t send(const rapidjson::Value& obj, Callback callback) override { return 0; }
|
inline int64_t send(const rapidjson::Value &, Callback) override { return 0; }
|
||||||
inline int64_t send(const rapidjson::Value& obj) override { return 0; }
|
inline int64_t send(const rapidjson::Value &) override { return 0; }
|
||||||
inline int64_t sequence() const override { return 0; }
|
inline int64_t sequence() const override { return 0; }
|
||||||
inline int64_t submit(const JobResult& result) override { return 0; }
|
inline int64_t submit(const JobResult &) override { return 0; }
|
||||||
inline void connect(const Pool& pool) override { setPool(pool); }
|
inline void connect(const Pool &pool) override { setPool(pool); }
|
||||||
inline void deleteLater() override {}
|
inline void deleteLater() override {}
|
||||||
inline void setAlgo(const Algorithm& algo) override {}
|
inline void setAlgo(const Algorithm &algo) override {}
|
||||||
inline void setEnabled(bool enabled) override {}
|
inline void setEnabled(bool enabled) override {}
|
||||||
inline void setProxy(const ProxyUrl& proxy) override {}
|
inline void setProxy(const ProxyUrl &proxy) override {}
|
||||||
inline void setQuiet(bool quiet) override {}
|
inline void setQuiet(bool quiet) override {}
|
||||||
inline void setRetries(int retries) override {}
|
inline void setRetries(int retries) override {}
|
||||||
inline void setRetryPause(uint64_t ms) override {}
|
inline void setRetryPause(uint64_t ms) override {}
|
||||||
inline void tick(uint64_t now) override {}
|
inline void tick(uint64_t now) override {}
|
||||||
|
|
||||||
void connect() override;
|
void connect() override;
|
||||||
void setPool(const Pool& pool) override;
|
void setPool(const Pool &pool) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IClientListener* m_listener;
|
IClientListener* m_listener;
|
||||||
Job m_job;
|
Job m_job;
|
||||||
Pool m_pool;
|
Pool m_pool;
|
||||||
|
std::shared_ptr<BenchConfig> m_benchmark;
|
||||||
String m_ip;
|
String m_ip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,4 +75,4 @@ private:
|
||||||
} /* namespace xmrig */
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
#endif /* XMRIG_NULLCLIENT_H */
|
#endif /* XMRIG_BENCHCLIENT_H */
|
86
src/base/net/stratum/benchmark/BenchConfig.cpp
Normal file
86
src/base/net/stratum/benchmark/BenchConfig.cpp
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* 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 "base/net/stratum/benchmark/BenchConfig.h"
|
||||||
|
#include "3rdparty/rapidjson/document.h"
|
||||||
|
#include "base/io/json/Json.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
const char *BenchConfig::kAlgo = "algo";
|
||||||
|
const char *BenchConfig::kBenchmark = "benchmark";
|
||||||
|
const char *BenchConfig::kHash = "hash";
|
||||||
|
const char *BenchConfig::kSeed = "seed";
|
||||||
|
const char *BenchConfig::kSize = "size";
|
||||||
|
const char *BenchConfig::kSubmit = "submit";
|
||||||
|
const char *BenchConfig::kVerify = "verify";
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::BenchConfig::BenchConfig(uint32_t size, const String &id, const rapidjson::Value &object) :
|
||||||
|
m_algorithm(Json::getString(object, kAlgo)),
|
||||||
|
m_submit(Json::getBool(object, kSubmit)),
|
||||||
|
m_id(id),
|
||||||
|
m_seed(Json::getString(object, kSeed)),
|
||||||
|
m_size(size),
|
||||||
|
m_hash(0)
|
||||||
|
{
|
||||||
|
if (!m_algorithm.isValid() || m_algorithm.family() != Algorithm::RANDOM_X) {
|
||||||
|
m_algorithm = Algorithm::RX_0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::BenchConfig *xmrig::BenchConfig::create(const rapidjson::Value &object)
|
||||||
|
{
|
||||||
|
if (!object.IsObject() || object.ObjectEmpty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t size = getSize(Json::getString(object, kSize));
|
||||||
|
const String id = Json::getString(object, kVerify);
|
||||||
|
|
||||||
|
if (size == 0 && id.isEmpty()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BenchConfig(size, id, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t xmrig::BenchConfig::getSize(const char *benchmark)
|
||||||
|
{
|
||||||
|
if (!benchmark) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto size = strtoul(benchmark, nullptr, 10);
|
||||||
|
if (size < 1 || size > 10) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string s = std::to_string(size) + "M";
|
||||||
|
return strcasecmp(benchmark, s.c_str()) == 0 ? size * 1000000 : 0;
|
||||||
|
}
|
67
src/base/net/stratum/benchmark/BenchConfig.h
Normal file
67
src/base/net/stratum/benchmark/BenchConfig.h
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_BENCHCONFIG_H
|
||||||
|
#define XMRIG_BENCHCONFIG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/crypto/Algorithm.h"
|
||||||
|
#include "base/tools/String.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class BenchConfig
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const char *kAlgo;
|
||||||
|
static const char *kBenchmark;
|
||||||
|
static const char *kHash;
|
||||||
|
static const char *kSeed;
|
||||||
|
static const char *kSize;
|
||||||
|
static const char *kSubmit;
|
||||||
|
static const char *kVerify;
|
||||||
|
|
||||||
|
BenchConfig(uint32_t size, const String &id, const rapidjson::Value &object);
|
||||||
|
|
||||||
|
static BenchConfig *create(const rapidjson::Value &object);
|
||||||
|
|
||||||
|
inline bool isSubmit() const { return m_submit; }
|
||||||
|
inline const Algorithm &algorithm() const { return m_algorithm; }
|
||||||
|
inline const String &id() const { return m_id; }
|
||||||
|
inline const String &seed() const { return m_seed; }
|
||||||
|
inline uint32_t size() const { return m_size; }
|
||||||
|
inline uint64_t hash() const { return m_hash; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
static uint32_t getSize(const char *benchmark);
|
||||||
|
|
||||||
|
Algorithm m_algorithm;
|
||||||
|
bool m_submit;
|
||||||
|
String m_id;
|
||||||
|
String m_seed;
|
||||||
|
uint32_t m_size;
|
||||||
|
uint64_t m_hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_BENCHCONFIG_H */
|
|
@ -1,12 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -34,9 +28,7 @@ xmrig::FailoverStrategy::FailoverStrategy(const std::vector<Pool> &pools, int re
|
||||||
m_quiet(quiet),
|
m_quiet(quiet),
|
||||||
m_retries(retries),
|
m_retries(retries),
|
||||||
m_retryPause(retryPause),
|
m_retryPause(retryPause),
|
||||||
m_active(-1),
|
m_listener(listener)
|
||||||
m_listener(listener),
|
|
||||||
m_index(0)
|
|
||||||
{
|
{
|
||||||
for (const Pool &pool : pools) {
|
for (const Pool &pool : pools) {
|
||||||
add(pool);
|
add(pool);
|
||||||
|
@ -48,9 +40,7 @@ xmrig::FailoverStrategy::FailoverStrategy(int retryPause, int retries, IStrategy
|
||||||
m_quiet(quiet),
|
m_quiet(quiet),
|
||||||
m_retries(retries),
|
m_retries(retries),
|
||||||
m_retryPause(retryPause),
|
m_retryPause(retryPause),
|
||||||
m_active(-1),
|
m_listener(listener)
|
||||||
m_listener(listener),
|
|
||||||
m_index(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -78,9 +72,9 @@ private:
|
||||||
const bool m_quiet;
|
const bool m_quiet;
|
||||||
const int m_retries;
|
const int m_retries;
|
||||||
const int m_retryPause;
|
const int m_retryPause;
|
||||||
int m_active;
|
int m_active = -1;
|
||||||
IStrategyListener *m_listener;
|
IStrategyListener *m_listener;
|
||||||
size_t m_index;
|
size_t m_index = 0;
|
||||||
std::vector<IClient*> m_pools;
|
std::vector<IClient*> m_pools;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2020 cohcho <https://github.com/cohcho>
|
||||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2020 cohcho <https://github.com/cohcho>
|
||||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -36,6 +36,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
# include "base/net/stratum/benchmark/BenchConfig.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig
|
namespace xmrig
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -103,8 +108,6 @@ void xmrig::ConfigTransform::finalize(rapidjson::Document &doc)
|
||||||
BaseTransform::finalize(doc);
|
BaseTransform::finalize(doc);
|
||||||
|
|
||||||
if (m_threads) {
|
if (m_threads) {
|
||||||
doc.AddMember("version", 1, allocator);
|
|
||||||
|
|
||||||
if (!doc.HasMember(CpuConfig::kField)) {
|
if (!doc.HasMember(CpuConfig::kField)) {
|
||||||
doc.AddMember(StringRef(CpuConfig::kField), Value(kObjectType), allocator);
|
doc.AddMember(StringRef(CpuConfig::kField), Value(kObjectType), allocator);
|
||||||
}
|
}
|
||||||
|
@ -249,18 +252,14 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
case IConfig::StressKey: /* --stress */
|
case IConfig::AlgorithmKey: /* --algo */
|
||||||
case IConfig::BenchKey: /* --bench */
|
case IConfig::BenchKey: /* --bench */
|
||||||
set(doc, CpuConfig::kField, CpuConfig::kHugePagesJit, true);
|
case IConfig::StressKey: /* --stress */
|
||||||
set(doc, CpuConfig::kField, CpuConfig::kPriority, 2);
|
case IConfig::BenchSubmitKey: /* --submit */
|
||||||
set(doc, CpuConfig::kField, CpuConfig::kYield, false);
|
case IConfig::BenchVerifyKey: /* --verify */
|
||||||
|
case IConfig::BenchSeedKey: /* --seed */
|
||||||
add(doc, Pools::kPools, Pool::kUser, Pool::kBenchmark);
|
case IConfig::BenchHashKey: /* --hash */
|
||||||
|
return transformBenchmark(doc, key, arg);
|
||||||
if (key == IConfig::BenchKey) {
|
|
||||||
add(doc, Pools::kPools, Pool::kBenchmark, arg);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -310,3 +309,36 @@ void xmrig::ConfigTransform::transformUint64(rapidjson::Document &doc, int key,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
void xmrig::ConfigTransform::transformBenchmark(rapidjson::Document &doc, int key, const char *arg)
|
||||||
|
{
|
||||||
|
set(doc, CpuConfig::kField, CpuConfig::kHugePagesJit, true);
|
||||||
|
set(doc, CpuConfig::kField, CpuConfig::kPriority, 2);
|
||||||
|
set(doc, CpuConfig::kField, CpuConfig::kYield, false);
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case IConfig::AlgorithmKey: /* --algo */
|
||||||
|
return set(doc, BenchConfig::kBenchmark, BenchConfig::kAlgo, arg);
|
||||||
|
|
||||||
|
case IConfig::BenchKey: /* --bench */
|
||||||
|
return set(doc, BenchConfig::kBenchmark, BenchConfig::kSize, arg);
|
||||||
|
|
||||||
|
case IConfig::StressKey: /* --stress */
|
||||||
|
return add(doc, Pools::kPools, Pool::kUser, BenchConfig::kBenchmark);
|
||||||
|
|
||||||
|
case IConfig::BenchSubmitKey: /* --submit */
|
||||||
|
return set(doc, BenchConfig::kBenchmark, BenchConfig::kSubmit, true);
|
||||||
|
|
||||||
|
case IConfig::BenchVerifyKey: /* --verify */
|
||||||
|
return set(doc, BenchConfig::kBenchmark, BenchConfig::kVerify, arg);
|
||||||
|
|
||||||
|
case IConfig::BenchSeedKey: /* --seed */
|
||||||
|
return set(doc, BenchConfig::kBenchmark, BenchConfig::kSeed, arg);
|
||||||
|
|
||||||
|
case IConfig::BenchHashKey: /* --hash */
|
||||||
|
return set(doc, BenchConfig::kBenchmark, BenchConfig::kHash, arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,10 @@ private:
|
||||||
void transformBoolean(rapidjson::Document &doc, int key, bool enable);
|
void transformBoolean(rapidjson::Document &doc, int key, bool enable);
|
||||||
void transformUint64(rapidjson::Document &doc, int key, uint64_t arg);
|
void transformUint64(rapidjson::Document &doc, int key, uint64_t arg);
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
void transformBenchmark(rapidjson::Document &doc, int key, const char *arg);
|
||||||
|
# endif
|
||||||
|
|
||||||
bool m_opencl = false;
|
bool m_opencl = false;
|
||||||
int64_t m_affinity = -1;
|
int64_t m_affinity = -1;
|
||||||
uint64_t m_intensity = 1;
|
uint64_t m_intensity = 1;
|
||||||
|
|
|
@ -100,6 +100,10 @@ static const option options[] = {
|
||||||
{ "stress", 0, nullptr, IConfig::StressKey },
|
{ "stress", 0, nullptr, IConfig::StressKey },
|
||||||
{ "bench", 1, nullptr, IConfig::BenchKey },
|
{ "bench", 1, nullptr, IConfig::BenchKey },
|
||||||
{ "benchmark", 1, nullptr, IConfig::BenchKey },
|
{ "benchmark", 1, nullptr, IConfig::BenchKey },
|
||||||
|
{ "submit", 0, nullptr, IConfig::BenchSubmitKey },
|
||||||
|
{ "verify", 1, nullptr, IConfig::BenchVerifyKey },
|
||||||
|
{ "seed", 1, nullptr, IConfig::BenchSeedKey },
|
||||||
|
{ "hash", 1, nullptr, IConfig::BenchHashKey },
|
||||||
# endif
|
# endif
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
{ "tls", 0, nullptr, IConfig::TlsKey },
|
{ "tls", 0, nullptr, IConfig::TlsKey },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue