@@ -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 ) {
@@ -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
484502function 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
555573function 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