From e3727f01b8da6a860f8e9e86b490d6bbbf6a8154 Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 12 Nov 2020 11:15:43 +0700 Subject: [PATCH] Added 250K and 500K offline benchmarks. --- src/backend/common/Benchmark.cpp | 43 +++++++++++++++---- src/base/net/stratum/Pools.cpp | 10 +++++ src/base/net/stratum/Pools.h | 2 +- .../net/stratum/benchmark/BenchConfig.cpp | 10 +++-- src/net/Network.cpp | 12 +++--- 5 files changed, 60 insertions(+), 17 deletions(-) diff --git a/src/backend/common/Benchmark.cpp b/src/backend/common/Benchmark.cpp index d6020916..ba1daf1c 100644 --- a/src/backend/common/Benchmark.cpp +++ b/src/backend/common/Benchmark.cpp @@ -37,9 +37,35 @@ namespace xmrig { -static uint64_t hashCheck[2][10] = { - { 0x898B6E0431C28A6BULL, 0xEE9468F8B40926BCULL, 0xC2BC5D11724813C0ULL, 0x3A2C7B285B87F941ULL, 0x3B5BD2C3A16B450EULL, 0x5CD0602F20C5C7C4ULL, 0x101DE939474B6812ULL, 0x52B765A1B156C6ECULL, 0x323935102AB6B45CULL, 0xB5231262E2792B26ULL }, - { 0x0F3E5400B39EA96AULL, 0x85944CCFA2752D1FULL, 0x64AFFCAE991811BAULL, 0x3E4D0B836D3B13BAULL, 0xEB7417D621271166ULL, 0x97FFE10C0949FFA5ULL, 0x84CAC0F8879A4BA1ULL, 0xA1B79F031DA2459FULL, 0x9B65226DA873E65DULL, 0x0F9E00C5A511C200ULL }, +static const std::map > hashCheck = { + { Algorithm::RX_0, { + { 250000U, 0x7D6054757BB08A63ULL }, + { 500000U, 0x96607546DE1F5ECCULL }, + { 1000000U, 0x898B6E0431C28A6BULL }, + { 2000000U, 0xEE9468F8B40926BCULL }, + { 3000000U, 0xC2BC5D11724813C0ULL }, + { 4000000U, 0x3A2C7B285B87F941ULL }, + { 5000000U, 0x3B5BD2C3A16B450EULL }, + { 6000000U, 0x5CD0602F20C5C7C4ULL }, + { 7000000U, 0x101DE939474B6812ULL }, + { 8000000U, 0x52B765A1B156C6ECULL }, + { 9000000U, 0x323935102AB6B45CULL }, + { 10000000U, 0xB5231262E2792B26ULL } + }}, + { Algorithm::RX_WOW, { + { 250000U, 0xC7F712C9603E2603ULL }, + { 500000U, 0x21A0E5AAE6DA7D8DULL }, + { 1000000U, 0x0F3E5400B39EA96AULL }, + { 2000000U, 0x85944CCFA2752D1FULL }, + { 3000000U, 0x64AFFCAE991811BAULL }, + { 4000000U, 0x3E4D0B836D3B13BAULL }, + { 5000000U, 0xEB7417D621271166ULL }, + { 6000000U, 0x97FFE10C0949FFA5ULL }, + { 7000000U, 0x84CAC0F8879A4BA1ULL }, + { 8000000U, 0xA1B79F031DA2459FULL }, + { 9000000U, 0x9B65226DA873E65DULL }, + { 10000000U, 0x0F9E00C5A511C200ULL } + }} }; @@ -185,12 +211,13 @@ uint64_t xmrig::Benchmark::referenceHash() const } # endif - const uint32_t N = (m_end / 1000000) - 1; - if (((m_algo == Algorithm::RX_0) || (m_algo == Algorithm::RX_WOW)) && ((m_end % 1000000) == 0) && (N < 10)) { - return hashCheck[(m_algo == Algorithm::RX_0) ? 0 : 1][N]; - } + uint64_t hash = 0; - return 0; + try { + hash = hashCheck.at(m_algo).at(m_end); + } catch (const std::exception &ex) {} + + return hash; } diff --git a/src/base/net/stratum/Pools.cpp b/src/base/net/stratum/Pools.cpp index cadc67ab..2e4a1101 100644 --- a/src/base/net/stratum/Pools.cpp +++ b/src/base/net/stratum/Pools.cpp @@ -70,6 +70,16 @@ bool xmrig::Pools::isEqual(const Pools &other) const } +int xmrig::Pools::donateLevel() const +{ +# ifdef XMRIG_FEATURE_BENCHMARK + return benchSize() || (m_benchmark && !m_benchmark->id().isEmpty()) ? 0 : m_donateLevel; +# else + return m_donateLevel; +# endif +} + + xmrig::IStrategy *xmrig::Pools::createStrategy(IStrategyListener *listener) const { if (active() == 1) { diff --git a/src/base/net/stratum/Pools.h b/src/base/net/stratum/Pools.h index 42262f2d..b4b4e0a2 100644 --- a/src/base/net/stratum/Pools.h +++ b/src/base/net/stratum/Pools.h @@ -58,7 +58,6 @@ public: Pools(); inline const std::vector &data() const { return m_data; } - inline int donateLevel() const { return benchSize() ? 0 : m_donateLevel; } inline int retries() const { return m_retries; } inline int retryPause() const { return m_retryPause; } inline ProxyDonate proxyDonate() const { return m_proxyDonate; } @@ -67,6 +66,7 @@ public: inline bool operator==(const Pools &other) const { return isEqual(other); } bool isEqual(const Pools &other) const; + int donateLevel() const; IStrategy *createStrategy(IStrategyListener *listener) const; rapidjson::Value toJSON(rapidjson::Document &doc) const; size_t active() const; diff --git a/src/base/net/stratum/benchmark/BenchConfig.cpp b/src/base/net/stratum/benchmark/BenchConfig.cpp index c52ac1c2..fc5661f5 100644 --- a/src/base/net/stratum/benchmark/BenchConfig.cpp +++ b/src/base/net/stratum/benchmark/BenchConfig.cpp @@ -96,9 +96,13 @@ uint32_t xmrig::BenchConfig::getSize(const char *benchmark) } const auto size = strtoul(benchmark, nullptr, 10); - if (size < 1 || size > 10) { - return 0; + if (size >= 1 && size <= 10) { + return strcasecmp(benchmark, fmt::format("{}M", size).c_str()) == 0 ? size * 1000000 : 0; } - return strcasecmp(benchmark, fmt::format("{}M", size).c_str()) == 0 ? size * 1000000 : 0; + if (size == 250 || size == 500) { + return strcasecmp(benchmark, fmt::format("{}K", size).c_str()) == 0 ? size * 1000 : 0; + } + + return 0; } diff --git a/src/net/Network.cpp b/src/net/Network.cpp index 1c1aa8e2..07999ab9 100644 --- a/src/net/Network.cpp +++ b/src/net/Network.cpp @@ -260,14 +260,16 @@ void xmrig::Network::onRequest(IApiRequest &request) void xmrig::Network::setJob(IClient *client, const Job &job, bool donate) { - uint64_t diff = job.diff();; - const char *scale = NetworkState::scaleDiff(diff); + uint64_t diff = job.diff();; + const char *scale = NetworkState::scaleDiff(diff); + const uint32_t size = job.benchSize(); # ifdef XMRIG_FEATURE_BENCHMARK - if (job.benchSize()) { - LOG_NOTICE("%s " MAGENTA_BOLD("start benchmark ") "hashes " CYAN_BOLD("%" PRIu64 "M") " algo " WHITE_BOLD("%s") " print_time " CYAN_BOLD("%us"), + if (size) { + LOG_NOTICE("%s " MAGENTA_BOLD("start benchmark ") "hashes " CYAN_BOLD("%u%s") " algo " WHITE_BOLD("%s") " print_time " CYAN_BOLD("%us"), Tags::bench(), - job.benchSize() / 1000000, + size < 1000000 ? size / 1000 : size / 1000000, + size < 1000000 ? "K" : "M", job.algorithm().shortName(), m_controller->config()->printTime());