Skip to content

Commit 225860a

Browse files
committed
Add regexes: ethminer, T-Rex, lolMiner, PhoenixMiner; Edit ethash test: diff, blob;
1 parent 7e55640 commit 225860a

1 file changed

Lines changed: 103 additions & 41 deletions

File tree

mm.js

Lines changed: 103 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,37 @@ const AGENT = "Meta Miner " + VERSION;
4242
// the multiplier is for supporting hashrate prints in different units
4343
// the nr benchmark prints is to make sure hashrate has stabilized before snapping the benchmark value
4444
const hashrate_regexes = [
45-
[1, 1, /\[[^\]]+\] speed 2.5s\/60s\/15m [\d\.]+ ([\d\.]+)\s/], // for old xmrig
46-
[1, 1, /\[[^\]]+\] speed 10s\/60s\/15m [\d\.n/a]+ ([\d\.]+)\s/], // for new xmrig
47-
[1, 1, /\s+miner\s+speed 10s\/60s\/15m [\d\.n/a]+ ([\d\.]+)\s/], // for xmrig v6+
48-
[1, 1, /Totals \(ALL\):\s+[\d\.]+\s+([1-9]\d*\.\d+|0\.[1-9]\d*)\s/], // xmr-stak
49-
[1, 1, /Total Speed: ([\d\.]+) H\/s,/], // claymore
50-
[1, 1, /\(Avr ([\d\.]+)H\/s\)/], // CryptoDredge
51-
[1e3, 3, /Total[^:]+:\s*([\d\.]+)\s*kh\/s/], // TeamRedMiner variant 1 (kh/s)
52-
[1, 3, /Total[^:]+:\s*([\d\.]+)\s*h\/s/], // TeamRedMiner variant 2 (h/s)
53-
[1, 1, /Mining at\s+([\d\.]+) gps/], // tube4referenceMiner (use mode=rolling command line option)
54-
[1, 1, /mining at\s+([\d\.]+) gps/], // SwapReferenceMiner (use mode=rolling command line option)
55-
[1, 2, /Total\s+:\s+([\d\.]+) gps/], // MoneroVMiner
56-
[1, 2, /([\d\.]+) G\/s/], // gminer
57-
[1000000, 2, /([\d\.]+) MH\/s/], // gminer
45+
[1, 2, /^\|.*[^\d.]([\d.]+) G\/s.*\|$/, 'gminer (gh/s)'],
46+
[1e6, 2, /^\|.*[^\d.]([\d.]+) M\/s.*\|$/, 'gminer (mh/s)'],
47+
[1, 3, /^\[[^\]]+] Total[^:]+:\s*([\d.]+)\s*[Hh]\/s/, 'TeamRedMiner (h/s)'],
48+
[1e3, 3, /^\[[^\]]+] Total[^:]+:\s*([\d.]+)\s*[Kk]h\/s/, 'TeamRedMiner (kh/s)'],
49+
[1e6, 3, /^\[[^\]]+] Total[^:]+:\s*([\d.]+)\s*[Mm]h\/s,/, 'TeamRedMiner (mh/s)'],
50+
[1e9, 3, /^\[[^\]]+] Total[^:]+:\s*([\d.]+)\s*[Gg]h\/s,/, 'TeamRedMiner (gh/s)'],
51+
[1, 2, /^ethminer .* ([\d.]+) h - /, 'ethminer (h/s)'],
52+
[1e3, 2, /^ethminer .* ([\d.]+) Kh - /, 'ethminer (kh/s)'],
53+
[1e6, 2, /^ethminer .* ([\d.]+) Mh - /, 'ethminer (mh/s)'],
54+
[1e9, 2, /^ethminer .* ([\d.]+) Gh - /, 'ethminer (gh/s)'],
55+
[1, 2, /^GPU #(\d+): .* - ([\d.]+) H\/s/, 'T-Rex (h/s)'],
56+
[1e3, 2, /^GPU #(\d+): .* - ([\d.]+) KH\/s/, 'T-Rex (kh/s)'],
57+
[1e6, 2, /^GPU #(\d+): .* - ([\d.]+) MH\/s/, 'T-Rex (mh/s)'],
58+
[1e9, 2, /^GPU #(\d+): .* - ([\d.]+) GH\/s/, 'T-Rex (gh/s)'],
59+
[1, 2, /^Average speed \(30s\): ([\d.]+) h\/s/, 'lolMiner (h/s)'],
60+
[1e3, 2, /^Average speed \(30s\): ([\d.]+) kh\/s/, 'lolMiner (kh/s)'],
61+
[1e6, 2, /^Average speed \(30s\): ([\d.]+) mh\/s/, 'lolMiner (mh/s)'],
62+
[1e9, 2, /^Average speed \(30s\): ([\d.]+) gh\/s/, 'lolMiner (gh/s)'],
63+
[1, 2, /^Eth speed: ([\d.]+) H\/s, shares:.*time:/, 'PhoenixMiner (h/s)'],
64+
[1e3, 2, /^Eth speed: ([\d.]+) KH\/s, shares:.*time:/, 'PhoenixMiner (kh/s)'],
65+
[1e6, 2, /^Eth speed: ([\d.]+) MH\/s, shares:.*time:/, 'PhoenixMiner (mh/s)'],
66+
[1e9, 2, /^Eth speed: ([\d.]+) GH\/s, shares:.*time:/, 'PhoenixMiner (gh/s)'],
67+
[1, 1, /\[[^\]]+] speed 2.5s\/60s\/15m [\d.]+ ([\d.]+)\s/, 'xmrig old'],
68+
[1, 1, /\[[^\]]+] speed 10s\/60s\/15m [\d.n/a]+ ([\d.]+)\s/, 'xmrig new'],
69+
[1, 1, /\s+miner\s+speed 10s\/60s\/15m [\d.n/a]+ ([\d.]+)\s/, 'xmrig v6+'],
70+
[1, 1, /Totals \(ALL\):\s+[\d.]+\s+([1-9]\d*\.\d+|0\.[1-9]\d*)\s/, 'xmr-stak'],
71+
[1, 1, /Total Speed: ([\d.]+) H\/s,/, 'claymore'],
72+
[1, 1, /\(Avr ([\d.]+)H\/s\)/, 'CryptoDredge'],
73+
[1, 1, /Mining at\s+([\d.]+) gps/, 'tube4referenceMiner (use mode=rolling command line option)'],
74+
[1, 1, /mining at\s+([\d.]+) gps/, 'SwapReferenceMiner (use mode=rolling command line option)'],
75+
[1, 2, /Total\s+:\s+([\d.]+) gps/, 'MoneroVMiner'],
5876
];
5977

6078
function algo_hashrate_factor(algo) {
@@ -478,7 +496,7 @@ function start_miner(cmd, out_cb) {
478496
let exe = args.shift();
479497
return start_miner_raw(exe, args, out_cb);
480498
}
481-
499+
482500
// *** Pool socket processing
483501

484502
function connect_pool(pool_num, pool_ok_cb, pool_new_msg_cb, pool_err_cb) {
@@ -500,7 +518,7 @@ function connect_pool(pool_num, pool_ok_cb, pool_new_msg_cb, pool_err_cb) {
500518
}) + "\n");
501519
});
502520

503-
let is_pool_ok = false;
521+
let is_pool_ok = false;
504522
let pool_data_buff = "";
505523

506524
pool_socket.on('data', function (msg) {
@@ -532,7 +550,7 @@ function connect_pool(pool_num, pool_ok_cb, pool_new_msg_cb, pool_err_cb) {
532550
} else err("Ignoring pool (" + c.pools[pool_num] + ") message since pool not reported no errors yet: " + JSON.stringify(json));
533551
}
534552
pool_data_buff = incomplete_line;
535-
553+
536554
});
537555

538556
pool_socket.on('end', function() {
@@ -549,7 +567,7 @@ function connect_pool(pool_num, pool_ok_cb, pool_new_msg_cb, pool_err_cb) {
549567
pool_err_cb(pool_num);
550568
});
551569
}
552-
570+
553571
// *** connect_pool function callbacks
554572

555573
function set_main_pool_check_timer() {
@@ -841,15 +859,15 @@ function do_miner_perf_runs(cb) {
841859
jsonrpc: "2.0",
842860
method: "mining.set_difficulty",
843861
params: [
844-
1000000
862+
10.24
845863
],
846864
}) + "\n" + JSON.stringify({
847865
jsonrpc: "2.0",
848866
method: "mining.notify",
849867
params: [
850868
"benchmark1", // job_id
851-
"e79f0f63030bf691445c2b9d0266b24a9619e355194067f2ad2c73a8e0a26c65", // seed hash
852-
"feb4243b885cd1af5337979f5d81849335cab197b4993e5c61ea4b43b43dbbc6", // hash
869+
"ffaad0781cfec93fee66657ef8a9f132f422becba3626b5d936ad3cb1f8228d4", // seed hash
870+
"a917c993b27e4a15c6ed3611bcaa7e5eee5c9b984053f6c1270032c0c4d6dc83", // hash
853871
true,
854872
]
855873
}) + "\n");
@@ -900,27 +918,70 @@ function do_miner_perf_runs(cb) {
900918
};
901919
let nr_prints_needed = -1;
902920
let nr_prints_found = 0;
903-
miner_proc = start_miner(cmd, function(str) {
904-
print_messages(str);
905-
str = str.replace(/\x1b\[[0-9;]*m/g, ""); // remove all colors
906-
for (let i in hashrate_regexes) {
907-
const hashrate_regex = hashrate_regexes[i];
908-
const m = str.match(hashrate_regex[2]);
909-
if (m) {
910-
if (nr_prints_needed < 0) nr_prints_needed = hashrate_regex[1];
911-
const hashrate = parseFloat(m[1]) * hashrate_regex[0] * algo_hashrate_factor(algo);
912-
if (++nr_prints_found >= nr_prints_needed) {
913-
const algo_deps = bench_algo_deps(algo, hashrate);
914-
for (let algo_dep in algo_deps) {
915-
log("Setting performance for " + algo_dep + " algo to " + algo_deps[algo_dep]);
916-
c.algo_perf[algo_dep] = algo_deps[algo_dep];
921+
let chunk_leftover = '';
922+
miner_proc = start_miner(cmd, function(chunk) {
923+
chunk = [chunk_leftover, chunk].join('');
924+
const buf_size = chunk.lastIndexOf('\n');
925+
chunk_leftover = chunk.slice(chunk, buf_size);
926+
const eol = `\x1b[0m\n`;
927+
let gpu_max = -1;
928+
let gpu_max_valid = false;
929+
const variance = [];
930+
const hashrate_raw = [];
931+
const hashrate_prev = [];
932+
processing:
933+
for (let str of chunk.split('\n')) {
934+
print_messages(str + eol);
935+
str = str.replace(/\x1b\[[0-9;]*m/g, ""); // remove all colors
936+
for (let i in hashrate_regexes) {
937+
const hashrate_regex = hashrate_regexes[i];
938+
const m = str.match(hashrate_regex[2]);
939+
if (m) {
940+
if (nr_prints_needed < 0) nr_prints_needed = hashrate_regex[1];
941+
let gpu = (m.length === 3) ? m[1] : 0;
942+
if (gpu_max > -1 && gpu <= gpu_max) gpu_max_valid = true;
943+
if (gpu > gpu_max) gpu_max = gpu;
944+
if (m.length === 3) {
945+
m[1] = m[2];
946+
m.length = 2;
947+
}
948+
hashrate_raw[gpu] = parseFloat(m[1]);
949+
if (!gpu_max_valid) {
950+
hashrate_prev[gpu] = hashrate_raw[gpu];
951+
} else if (hashrate_raw[gpu] > 0) {
952+
if (hashrate_prev.length < gpu) hashrate_prev[gpu] = hashrate_raw[gpu];
953+
variance[gpu] = hashrate_prev[gpu] / hashrate_raw[gpu];
954+
let variance_good = true;
955+
for (const j in variance) {
956+
if (!(variance[j] > 0.98 && variance[j] < 1.02)) {
957+
variance_good = false;
958+
}
959+
}
960+
if (gpu === gpu_max) {
961+
let hashrate = 0;
962+
for (const j in hashrate_raw) {
963+
hashrate += hashrate_raw[j] * hashrate_regex[0] * algo_hashrate_factor(algo);
964+
}
965+
if (variance_good && ++nr_prints_found >= nr_prints_needed) {
966+
const algo_deps = bench_algo_deps(algo, hashrate);
967+
for (let algo_dep in algo_deps) {
968+
log("Setting performance for " + algo_dep + " algo to " + algo_deps[algo_dep]);
969+
c.algo_perf[algo_dep] = algo_deps[algo_dep];
970+
}
971+
miner_proc.on('close', (code) => { clearTimeout(timeout); resolve(); });
972+
tree_kill(miner_proc.pid);
973+
break processing;
974+
} else {
975+
let msg = "Read";
976+
if (!variance_good) {
977+
msg = "Skip";
978+
}
979+
log(msg + " performance for " + algo + " algo of " + hashrate + ", waiting for " +
980+
(nr_prints_needed - nr_prints_found) + " more print(s).");
981+
}
982+
}
983+
hashrate_prev[gpu] = hashrate_raw[gpu];
917984
}
918-
miner_proc.on('close', (code) => { clearTimeout(timeout); resolve(); });
919-
tree_kill(miner_proc.pid);
920-
break;
921-
} else {
922-
log("Read performance for " + algo + " algo to " + hashrate + ", waiting for " +
923-
(nr_prints_needed - nr_prints_found) + " more print(s).");
924985
}
925986
}
926987
}
@@ -1110,6 +1171,7 @@ function main() {
11101171
};
11111172
miner_get_first_job_cb = function(json, miner_socket) {
11121173
if (curr_pool_last_job) {
1174+
let reply;
11131175
switch (curr_miner_protocol) {
11141176
case "grin":
11151177
miner_socket_write(miner_socket, grin_json_reply("getjobtemplate", curr_pool_last_job));
@@ -1127,7 +1189,7 @@ function main() {
11271189
break;
11281190

11291191
default:
1130-
let reply = { jsonrpc: "2.0", error: null, result: { id: curr_pool_miner_id, job: curr_pool_last_job, status: "OK" } };
1192+
reply = {jsonrpc: "2.0", error: null, result: {id: curr_pool_miner_id, job: curr_pool_last_job, status: "OK"}};
11311193
if ("id" in json) reply.id = json.id;
11321194
miner_socket_write(miner_socket, JSON.stringify(reply) + "\n");
11331195
}

0 commit comments

Comments
 (0)