@@ -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
4444const hashrate_regexes = [
45- [ 1 , 1 , / \[ [ ^ \] ] + \] s p e e d 2 .5 s \/ 6 0 s \/ 1 5 m [ \d \. ] + ( [ \d \. ] + ) \s / ] , // for old xmrig
46- [ 1 , 1 , / \[ [ ^ \] ] + \] s p e e d 1 0 s \/ 6 0 s \/ 1 5 m [ \d \. n / a ] + ( [ \d \. ] + ) \s / ] , // for new xmrig
47- [ 1 , 1 , / \s + m i n e r \s + s p e e d 1 0 s \/ 6 0 s \/ 1 5 m [ \d \. n / a ] + ( [ \d \. ] + ) \s / ] , // for xmrig v6+
48- [ 1 , 1 , / T o t a l s \( A L L \) : \s + [ \d \. ] + \s + ( [ 1 - 9 ] \d * \. \d + | 0 \. [ 1 - 9 ] \d * ) \s / ] , // xmr-stak
49- [ 1 , 1 , / T o t a l S p e e d : ( [ \d \. ] + ) H \/ s , / ] , // claymore
50- [ 1 , 1 , / \( A v r ( [ \d \. ] + ) H \/ s \) / ] , // CryptoDredge
51- [ 1e3 , 3 , / T o t a l [ ^ : ] + : \s * ( [ \d \. ] + ) \s * k h \/ s / ] , // TeamRedMiner variant 1 (kh/s)
52- [ 1 , 3 , / T o t a l [ ^ : ] + : \s * ( [ \d \. ] + ) \s * h \/ s / ] , // TeamRedMiner variant 2 (h/s)
53- [ 1 , 1 , / M i n i n g a t \s + ( [ \d \. ] + ) g p s / ] , // tube4referenceMiner (use mode=rolling command line option)
54- [ 1 , 1 , / m i n i n g a t \s + ( [ \d \. ] + ) g p s / ] , // SwapReferenceMiner (use mode=rolling command line option)
55- [ 1 , 2 , / T o t a l \s + : \s + ( [ \d \. ] + ) g p s / ] , // MoneroVMiner
56- [ 1 , 2 , / ( [ \d \. ] + ) G \/ s / ] , // gminer
57- [ 1000000 , 2 , / ( [ \d \. ] + ) M H \/ 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 , / ^ \[ [ ^ \] ] + ] T o t a l [ ^ : ] + : \s * ( [ \d . ] + ) \s * [ H h ] \/ s / , 'TeamRedMiner (h/s)' ] ,
48+ [ 1e3 , 3 , / ^ \[ [ ^ \] ] + ] T o t a l [ ^ : ] + : \s * ( [ \d . ] + ) \s * [ K k ] h \/ s / , 'TeamRedMiner (kh/s)' ] ,
49+ [ 1e6 , 3 , / ^ \[ [ ^ \] ] + ] T o t a l [ ^ : ] + : \s * ( [ \d . ] + ) \s * [ M m ] h \/ s , / , 'TeamRedMiner (mh/s)' ] ,
50+ [ 1e9 , 3 , / ^ \[ [ ^ \] ] + ] T o t a l [ ^ : ] + : \s * ( [ \d . ] + ) \s * [ G g ] h \/ s , / , 'TeamRedMiner (gh/s)' ] ,
51+ [ 1 , 2 , / ^ e t h m i n e r .* ( [ \d . ] + ) h - / , 'ethminer (h/s)' ] ,
52+ [ 1e3 , 2 , / ^ e t h m i n e r .* ( [ \d . ] + ) K h - / , 'ethminer (kh/s)' ] ,
53+ [ 1e6 , 2 , / ^ e t h m i n e r .* ( [ \d . ] + ) M h - / , 'ethminer (mh/s)' ] ,
54+ [ 1e9 , 2 , / ^ e t h m i n e r .* ( [ \d . ] + ) G h - / , 'ethminer (gh/s)' ] ,
55+ [ 1 , 2 , / ^ G P U # ( \d + ) : .* - ( [ \d . ] + ) H \/ s / , 'T-Rex (h/s)' ] ,
56+ [ 1e3 , 2 , / ^ G P U # ( \d + ) : .* - ( [ \d . ] + ) K H \/ s / , 'T-Rex (kh/s)' ] ,
57+ [ 1e6 , 2 , / ^ G P U # ( \d + ) : .* - ( [ \d . ] + ) M H \/ s / , 'T-Rex (mh/s)' ] ,
58+ [ 1e9 , 2 , / ^ G P U # ( \d + ) : .* - ( [ \d . ] + ) G H \/ s / , 'T-Rex (gh/s)' ] ,
59+ [ 1 , 2 , / ^ A v e r a g e s p e e d \( 3 0 s \) : ( [ \d . ] + ) h \/ s / , 'lolMiner (h/s)' ] ,
60+ [ 1e3 , 2 , / ^ A v e r a g e s p e e d \( 3 0 s \) : ( [ \d . ] + ) k h \/ s / , 'lolMiner (kh/s)' ] ,
61+ [ 1e6 , 2 , / ^ A v e r a g e s p e e d \( 3 0 s \) : ( [ \d . ] + ) m h \/ s / , 'lolMiner (mh/s)' ] ,
62+ [ 1e9 , 2 , / ^ A v e r a g e s p e e d \( 3 0 s \) : ( [ \d . ] + ) g h \/ s / , 'lolMiner (gh/s)' ] ,
63+ [ 1 , 2 , / ^ E t h s p e e d : ( [ \d . ] + ) H \/ s , s h a r e s : .* t i m e : / , 'PhoenixMiner (h/s)' ] ,
64+ [ 1e3 , 2 , / ^ E t h s p e e d : ( [ \d . ] + ) K H \/ s , s h a r e s : .* t i m e : / , 'PhoenixMiner (kh/s)' ] ,
65+ [ 1e6 , 2 , / ^ E t h s p e e d : ( [ \d . ] + ) M H \/ s , s h a r e s : .* t i m e : / , 'PhoenixMiner (mh/s)' ] ,
66+ [ 1e9 , 2 , / ^ E t h s p e e d : ( [ \d . ] + ) G H \/ s , s h a r e s : .* t i m e : / , 'PhoenixMiner (gh/s)' ] ,
67+ [ 1 , 1 , / \[ [ ^ \] ] + ] s p e e d 2 .5 s \/ 6 0 s \/ 1 5 m [ \d . ] + ( [ \d . ] + ) \s / , 'xmrig old' ] ,
68+ [ 1 , 1 , / \[ [ ^ \] ] + ] s p e e d 1 0 s \/ 6 0 s \/ 1 5 m [ \d . n / a ] + ( [ \d . ] + ) \s / , 'xmrig new' ] ,
69+ [ 1 , 1 , / \s + m i n e r \s + s p e e d 1 0 s \/ 6 0 s \/ 1 5 m [ \d . n / a ] + ( [ \d . ] + ) \s / , 'xmrig v6+' ] ,
70+ [ 1 , 1 , / T o t a l s \( A L L \) : \s + [ \d . ] + \s + ( [ 1 - 9 ] \d * \. \d + | 0 \. [ 1 - 9 ] \d * ) \s / , 'xmr-stak' ] ,
71+ [ 1 , 1 , / T o t a l S p e e d : ( [ \d . ] + ) H \/ s , / , 'claymore' ] ,
72+ [ 1 , 1 , / \( A v r ( [ \d . ] + ) H \/ s \) / , 'CryptoDredge' ] ,
73+ [ 1 , 1 , / M i n i n g a t \s + ( [ \d . ] + ) g p s / , 'tube4referenceMiner (use mode=rolling command line option)' ] ,
74+ [ 1 , 1 , / m i n i n g a t \s + ( [ \d . ] + ) g p s / , 'SwapReferenceMiner (use mode=rolling command line option)' ] ,
75+ [ 1 , 2 , / T o t a l \s + : \s + ( [ \d . ] + ) g p s / , 'MoneroVMiner' ] ,
5876] ;
5977
6078function algo_hashrate_factor ( algo ) {
@@ -482,7 +500,7 @@ function start_miner(cmd, out_cb) {
482500 let exe = args . shift ( ) ;
483501 return start_miner_raw ( exe , args , out_cb ) ;
484502}
485-
503+
486504// *** Pool socket processing
487505
488506function connect_pool ( pool_num , pool_ok_cb , pool_new_msg_cb , pool_err_cb ) {
@@ -504,7 +522,7 @@ function connect_pool(pool_num, pool_ok_cb, pool_new_msg_cb, pool_err_cb) {
504522 } ) + "\n" ) ;
505523 } ) ;
506524
507- let is_pool_ok = false ;
525+ let is_pool_ok = false ;
508526 let pool_data_buff = "" ;
509527
510528 pool_socket . on ( 'data' , function ( msg ) {
@@ -536,7 +554,7 @@ function connect_pool(pool_num, pool_ok_cb, pool_new_msg_cb, pool_err_cb) {
536554 } else err ( "Ignoring pool (" + c . pools [ pool_num ] + ") message since pool not reported no errors yet: " + JSON . stringify ( json ) ) ;
537555 }
538556 pool_data_buff = incomplete_line ;
539-
557+
540558 } ) ;
541559
542560 pool_socket . on ( 'end' , function ( ) {
@@ -553,7 +571,7 @@ function connect_pool(pool_num, pool_ok_cb, pool_new_msg_cb, pool_err_cb) {
553571 pool_err_cb ( pool_num ) ;
554572 } ) ;
555573}
556-
574+
557575// *** connect_pool function callbacks
558576
559577function set_main_pool_check_timer ( ) {
@@ -845,15 +863,15 @@ function do_miner_perf_runs(cb) {
845863 jsonrpc : "2.0" ,
846864 method : "mining.set_difficulty" ,
847865 params : [
848- 1000000
866+ 10.24
849867 ] ,
850868 } ) + "\n" + JSON . stringify ( {
851869 jsonrpc : "2.0" ,
852870 method : "mining.notify" ,
853871 params : [
854872 "benchmark1" , // job_id
855- "e79f0f63030bf691445c2b9d0266b24a9619e355194067f2ad2c73a8e0a26c65 " , // seed hash
856- "feb4243b885cd1af5337979f5d81849335cab197b4993e5c61ea4b43b43dbbc6 " , // hash
873+ "ffaad0781cfec93fee66657ef8a9f132f422becba3626b5d936ad3cb1f8228d4 " , // seed hash
874+ "a917c993b27e4a15c6ed3611bcaa7e5eee5c9b984053f6c1270032c0c4d6dc83 " , // hash
857875 true ,
858876 ]
859877 } ) + "\n" ) ;
@@ -904,27 +922,70 @@ function do_miner_perf_runs(cb) {
904922 } ;
905923 let nr_prints_needed = - 1 ;
906924 let nr_prints_found = 0 ;
907- miner_proc = start_miner ( cmd , function ( str ) {
908- print_messages ( str ) ;
909- str = str . replace ( / \x1b \[ [ 0 - 9 ; ] * m / g, "" ) ; // remove all colors
910- for ( let i in hashrate_regexes ) {
911- const hashrate_regex = hashrate_regexes [ i ] ;
912- const m = str . match ( hashrate_regex [ 2 ] ) ;
913- if ( m ) {
914- if ( nr_prints_needed < 0 ) nr_prints_needed = hashrate_regex [ 1 ] ;
915- const hashrate = parseFloat ( m [ 1 ] ) * hashrate_regex [ 0 ] * algo_hashrate_factor ( algo ) ;
916- if ( ++ nr_prints_found >= nr_prints_needed ) {
917- const algo_deps = bench_algo_deps ( algo , hashrate ) ;
918- for ( let algo_dep in algo_deps ) {
919- log ( "Setting performance for " + algo_dep + " algo to " + algo_deps [ algo_dep ] ) ;
920- c . algo_perf [ algo_dep ] = algo_deps [ algo_dep ] ;
925+ let chunk_leftover = '' ;
926+ miner_proc = start_miner ( cmd , function ( chunk ) {
927+ chunk = [ chunk_leftover , chunk ] . join ( '' ) ;
928+ const buf_size = chunk . lastIndexOf ( '\n' ) ;
929+ chunk_leftover = chunk . slice ( chunk , buf_size ) ;
930+ const eol = `\x1b[0m\n` ;
931+ let gpu_max = - 1 ;
932+ let gpu_max_valid = false ;
933+ const variance = [ ] ;
934+ const hashrate_raw = [ ] ;
935+ const hashrate_prev = [ ] ;
936+ processing:
937+ for ( let str of chunk . split ( '\n' ) ) {
938+ print_messages ( str + eol ) ;
939+ str = str . replace ( / \x1b \[ [ 0 - 9 ; ] * m / g, "" ) ; // remove all colors
940+ for ( let i in hashrate_regexes ) {
941+ const hashrate_regex = hashrate_regexes [ i ] ;
942+ const m = str . match ( hashrate_regex [ 2 ] ) ;
943+ if ( m ) {
944+ if ( nr_prints_needed < 0 ) nr_prints_needed = hashrate_regex [ 1 ] ;
945+ let gpu = ( m . length === 3 ) ? m [ 1 ] : 0 ;
946+ if ( gpu_max > - 1 && gpu <= gpu_max ) gpu_max_valid = true ;
947+ if ( gpu > gpu_max ) gpu_max = gpu ;
948+ if ( m . length === 3 ) {
949+ m [ 1 ] = m [ 2 ] ;
950+ m . length = 2 ;
951+ }
952+ hashrate_raw [ gpu ] = parseFloat ( m [ 1 ] ) ;
953+ if ( ! gpu_max_valid ) {
954+ hashrate_prev [ gpu ] = hashrate_raw [ gpu ] ;
955+ } else if ( hashrate_raw [ gpu ] > 0 ) {
956+ if ( hashrate_prev . length < gpu ) hashrate_prev [ gpu ] = hashrate_raw [ gpu ] ;
957+ variance [ gpu ] = hashrate_prev [ gpu ] / hashrate_raw [ gpu ] ;
958+ let variance_good = true ;
959+ for ( const j in variance ) {
960+ if ( ! ( variance [ j ] > 0.98 && variance [ j ] < 1.02 ) ) {
961+ variance_good = false ;
962+ }
963+ }
964+ if ( gpu === gpu_max ) {
965+ let hashrate = 0 ;
966+ for ( const j in hashrate_raw ) {
967+ hashrate += hashrate_raw [ j ] * hashrate_regex [ 0 ] * algo_hashrate_factor ( algo ) ;
968+ }
969+ if ( variance_good && ++ nr_prints_found >= nr_prints_needed ) {
970+ const algo_deps = bench_algo_deps ( algo , hashrate ) ;
971+ for ( let algo_dep in algo_deps ) {
972+ log ( "Setting performance for " + algo_dep + " algo to " + algo_deps [ algo_dep ] ) ;
973+ c . algo_perf [ algo_dep ] = algo_deps [ algo_dep ] ;
974+ }
975+ miner_proc . on ( 'close' , ( code ) => { clearTimeout ( timeout ) ; resolve ( ) ; } ) ;
976+ tree_kill ( miner_proc . pid ) ;
977+ break processing;
978+ } else {
979+ let msg = "Read" ;
980+ if ( ! variance_good ) {
981+ msg = "Skip" ;
982+ }
983+ log ( msg + " performance for " + algo + " algo of " + hashrate + ", waiting for " +
984+ ( nr_prints_needed - nr_prints_found ) + " more print(s)." ) ;
985+ }
986+ }
987+ hashrate_prev [ gpu ] = hashrate_raw [ gpu ] ;
921988 }
922- miner_proc . on ( 'close' , ( code ) => { clearTimeout ( timeout ) ; resolve ( ) ; } ) ;
923- tree_kill ( miner_proc . pid ) ;
924- break ;
925- } else {
926- log ( "Read performance for " + algo + " algo to " + hashrate + ", waiting for " +
927- ( nr_prints_needed - nr_prints_found ) + " more print(s)." ) ;
928989 }
929990 }
930991 }
@@ -1114,6 +1175,7 @@ function main() {
11141175 } ;
11151176 miner_get_first_job_cb = function ( json , miner_socket ) {
11161177 if ( curr_pool_last_job ) {
1178+ let reply ;
11171179 switch ( curr_miner_protocol ) {
11181180 case "grin" :
11191181 miner_socket_write ( miner_socket , grin_json_reply ( "getjobtemplate" , curr_pool_last_job ) ) ;
@@ -1131,7 +1193,7 @@ function main() {
11311193 break ;
11321194
11331195 default :
1134- let reply = { jsonrpc : "2.0" , error : null , result : { id : curr_pool_miner_id , job : curr_pool_last_job , status : "OK" } } ;
1196+ reply = { jsonrpc : "2.0" , error : null , result : { id : curr_pool_miner_id , job : curr_pool_last_job , status : "OK" } } ;
11351197 if ( "id" in json ) reply . id = json . id ;
11361198 miner_socket_write ( miner_socket , JSON . stringify ( reply ) + "\n" ) ;
11371199 }
0 commit comments