Improved MO benchmark logic

This commit is contained in:
MoneroOcean 2024-05-27 22:30:27 -07:00
parent 69b5f93a1b
commit a936d10725
3 changed files with 90 additions and 120 deletions

View file

@ -21,6 +21,7 @@
#include <map>
#include "net/interfaces/IJobResultListener.h"
#include "base/crypto/Algorithm.h"
#include "base/net/stratum/Job.h"
#include "rapidjson/fwd.h"
#include <memory>
@ -33,27 +34,7 @@ class Job;
class MoBenchmark : public IJobResultListener {
enum BenchAlgo : int {
FLEX_KCN, // "flex" Flex
GHOSTRIDER_RTM, // "ghostrider" GhostRider
CN_R, // "cn/r" CryptoNightR (Monero's variant 4).
CN_LITE_1, // "cn-lite/1" CryptoNight-Lite variant 1.
CN_HEAVY_XHV, // "cn-heavy/xhv" CryptoNight-Heavy (modified, Haven Protocol only).
CN_PICO_0, // "cn-pico" CryptoNight-Pico.
CN_CCX, // "cn/ccx" Conceal (CCX).
CN_GPU, // "cn/gpu" CryptoNight-GPU (Ryo).
AR2_CHUKWA_V2, // "argon2/chukwav2" Argon2id (Chukwa v2).
KAWPOW_RVN, // "kawpow/rvn" KawPow (RVN)
RX_0, // "rx/0" RandomX (Monero).
RX_GRAFT, // "rx/graft" RandomGraft (Graft).
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
RX_XLA, // "panthera" Panthera (Scala2).
MAX,
MIN = 0,
INVALID = -1,
};
const Algorithm::Id ba2a[BenchAlgo::MAX] = {
const Algorithm::Id bench_algos[15] = {
Algorithm::FLEX_KCN,
Algorithm::GHOSTRIDER_RTM,
Algorithm::CN_R,
@ -68,26 +49,26 @@ class MoBenchmark : public IJobResultListener {
Algorithm::RX_GRAFT,
Algorithm::RX_ARQ,
Algorithm::RX_XLA,
Algorithm::INVALID
};
Job* m_bench_job[BenchAlgo::MAX];
double m_bench_algo_perf[BenchAlgo::MAX];
Job m_bench_job;
Controller *m_controller; // to get access to config and network
bool m_isNewBenchRun; // true if benchmark is need to be executed or was executed
MoBenchmark::BenchAlgo m_bench_algo; // current perf algo we benchmark
uint64_t m_bench_algo; // current perf algo number we benchmark (in bench_algos array)
uint64_t m_hash_count; // number of hashes calculated for current perf algo
uint64_t m_time_start; // time of the first resultt for current perf algo (in ms)
uint64_t m_bench_start; // time of measurements start for current perf algo (in ms) after all backends are started
unsigned m_enabled_backend_count; // number of active miner backends
std::set<uint32_t> m_backends_started; // id of backend started for benchmark
uint64_t get_now() const; // get current time in ms
double get_algo_perf(Algorithm::Id algo) const; // get algo perf based on m_bench_algo_perf
void start(const MoBenchmark::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
void run_next_bench_algo(BenchAlgo); // run next bench algo or finish benchmark for the last one
uint64_t get_now() const; // get current time in ms
double get_algo_perf(Algorithm::Id algo) const; // get algo perf based on algo_perf known perf numbers
void start(); // start benchmark for m_bench_algo number
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
void run_next_bench_algo(); // run next bench algo or finish benchmark for the last one
public:
MoBenchmark();
@ -95,7 +76,8 @@ class MoBenchmark : public IJobResultListener {
void set_controller(std::shared_ptr<Controller> controller) { m_controller = controller.get(); }
void start(); // start benchmarks
void start_perf(); // start benchmarks
void flush_perf();
bool isNewBenchRun() const { return m_isNewBenchRun; }
mutable std::map<Algorithm::Id, double> algo_perf;