From 8727d79182c99f2163a245bd576edfd7c4c328e0 Mon Sep 17 00:00:00 2001 From: Jay D Dee Date: Wed, 12 Jan 2022 21:08:25 -0500 Subject: [PATCH] v3.19.4 --- RELEASE_NOTES | 9 +++++++++ algo/verthash/Verthash.c | 17 +++++++++-------- configure | 20 ++++++++++---------- configure.ac | 2 +- cpu-miner.c | 39 +++++++++++++++++++++++++++++++++++---- miner.h | 3 +++ util.c | 19 +++++++++++++++++++ 7 files changed, 86 insertions(+), 23 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 9f3fb6a..441c15d 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -65,6 +65,15 @@ If not what makes it happen or not happen? Change Log ---------- +v3.19.4 + +#359: Fix verthash memory allocation for non-hugepages, broken in v3.19.3. + +New option stratum-keepalive prevents stratum timeouts when no shares are +submitted for several minutes due to high difficulty. + +Fixed a bug displaying optimizations for some algos. + v3.19.3 Linux: Faster verthash (+25%), scryptn2 (+2%) when huge pages are available. diff --git a/algo/verthash/Verthash.c b/algo/verthash/Verthash.c index 2952112..553bb6a 100644 --- a/algo/verthash/Verthash.c +++ b/algo/verthash/Verthash.c @@ -87,16 +87,17 @@ int verthash_info_init(verthash_info_t* info, const char* file_name) // Allocate data info->data = (uint8_t *)malloc_hugepages( fileSize ); if ( info->data ) - if ( !opt_quiet ) applog( LOG_INFO, "Verthash data is using huge pages"); - else { + if ( !opt_quiet ) applog( LOG_INFO, "Verthash data is using huge pages"); + } + else info->data = (uint8_t *)_mm_malloc( fileSize, 64 ); - if (!info->data) - { - fclose(fileMiningData); - // Memory allocation fatal error. - return 2; - } + + if ( !info->data ) + { + fclose( fileMiningData ); + // Memory allocation fatal error. + return 2; } // Load data diff --git a/configure b/configure index e76f139..6c1104c 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.19.3. +# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.19.4. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='cpuminer-opt' PACKAGE_TARNAME='cpuminer-opt' -PACKAGE_VERSION='3.19.3' -PACKAGE_STRING='cpuminer-opt 3.19.3' +PACKAGE_VERSION='3.19.4' +PACKAGE_STRING='cpuminer-opt 3.19.4' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1332,7 +1332,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures cpuminer-opt 3.19.3 to adapt to many kinds of systems. +\`configure' configures cpuminer-opt 3.19.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1404,7 +1404,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of cpuminer-opt 3.19.3:";; + short | recursive ) echo "Configuration of cpuminer-opt 3.19.4:";; esac cat <<\_ACEOF @@ -1509,7 +1509,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -cpuminer-opt configure 3.19.3 +cpuminer-opt configure 3.19.4 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2012,7 +2012,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by cpuminer-opt $as_me 3.19.3, which was +It was created by cpuminer-opt $as_me 3.19.4, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2993,7 +2993,7 @@ fi # Define the identity of the package. PACKAGE='cpuminer-opt' - VERSION='3.19.3' + VERSION='3.19.4' cat >>confdefs.h <<_ACEOF @@ -6690,7 +6690,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by cpuminer-opt $as_me 3.19.3, which was +This file was extended by cpuminer-opt $as_me 3.19.4, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6756,7 +6756,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -cpuminer-opt config.status 3.19.3 +cpuminer-opt config.status 3.19.4 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 2b17493..3556758 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([cpuminer-opt], [3.19.3]) +AC_INIT([cpuminer-opt], [3.19.4]) AC_PREREQ([2.59c]) AC_CANONICAL_SYSTEM diff --git a/cpu-miner.c b/cpu-miner.c index 7a70f9f..abda606 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -127,6 +127,10 @@ char *short_url = NULL; char *coinbase_address; char *opt_data_file = NULL; bool opt_verify = false; +static bool opt_stratum_keepalive = false; +static struct timeval stratum_keepalive_timer; +// Stratum typically times out in 5 minutes or 300 seconds +#define stratum_keepalive_timeout 180 // 3 minutes // pk_buffer_size is used as a version selector by b58 code, therefore // it must be set correctly to work. @@ -2797,6 +2801,30 @@ static void *stratum_thread(void *userdata ) if ( stratum.new_job ) stratum_gen_work( &stratum, &g_work ); + // is keepalive needed? + if ( opt_stratum_keepalive ) + { + struct timeval now, et; + gettimeofday( &now, NULL ); + // any shares submitted since last keepalive? + if ( last_submit_time.tv_sec > stratum_keepalive_timer.tv_sec ) + memcpy( &stratum_keepalive_timer, &last_submit_time, + sizeof (struct timeval) ); + + timeval_subtract( &et, &now, &stratum_keepalive_timer ); + + if ( et.tv_sec > stratum_keepalive_timeout ) + { + double diff = stratum.job.diff * 0.5; + stratum_keepalive_timer = now; + if ( !opt_quiet ) + applog( LOG_BLUE, + "Stratum keepalive requesting lower difficulty" ); + stratum_suggest_difficulty( &stratum, diff ); + } + } + + // Wait for new message from server if ( likely( stratum_socket_full( &stratum, opt_timeout ) ) ) { if ( likely( s = stratum_recv_line( &stratum ) ) ) @@ -2818,7 +2846,6 @@ static void *stratum_thread(void *userdata ) stratum_need_reset = true; // stratum_disconnect( &stratum ); } - } // loop out: return NULL; @@ -2990,8 +3017,8 @@ static bool cpu_capability( bool display_only ) use_avx512 = cpu_has_avx512 && sw_has_avx512 && algo_has_avx512; use_sha = cpu_has_sha && sw_has_sha && algo_has_sha; use_vaes = cpu_has_vaes && sw_has_vaes && algo_has_vaes; - use_none = !( use_sse2 || use_aes || use_avx512 || use_avx2 || - use_sha || use_vaes ); + use_none = !( use_sse2 || use_sse42 || use_avx || use_aes || use_avx512 + || use_avx2 || use_sha || use_vaes ); // Display best options printf( "\nStarting miner with" ); @@ -3450,7 +3477,10 @@ void parse_arg(int key, char *arg ) case 1028: // verify opt_verify = true; break; - case 'V': + case 1029: // stratum-keepalive + opt_stratum_keepalive = true; + break; + case 'V': display_cpu_capability(); exit(0); case 'h': @@ -3899,6 +3929,7 @@ int main(int argc, char *argv[]) gettimeofday( &last_submit_time, NULL ); memcpy( &five_min_start, &last_submit_time, sizeof (struct timeval) ); memcpy( &session_start, &last_submit_time, sizeof (struct timeval) ); + memcpy( &stratum_keepalive_timer, &last_submit_time, sizeof (struct timeval) ); memcpy( &total_hashes_time, &last_submit_time, sizeof (struct timeval) ); pthread_mutex_unlock( &stats_lock ); diff --git a/miner.h b/miner.h index 9912411..903ddc1 100644 --- a/miner.h +++ b/miner.h @@ -466,6 +466,7 @@ void stratum_disconnect(struct stratum_ctx *sctx); bool stratum_subscribe(struct stratum_ctx *sctx); bool stratum_authorize(struct stratum_ctx *sctx, const char *user, const char *pass); bool stratum_handle_method(struct stratum_ctx *sctx, const char *s); +bool stratum_suggest_difficulty( struct stratum_ctx *sctx, double diff ); extern bool aes_ni_supported; @@ -918,6 +919,7 @@ Options:\n\ -c, --config=FILE load a JSON-format configuration file\n\ --data-file=FILE path and name of data file\n\ --verify enable additional time consuming start up tests\n\ + --stratum-keepalive Prevent disconnects when difficulty is too high\n\ -V, --version display version and CPU information and exit\n\ -h, --help display this help text and exit\n\ "; @@ -987,6 +989,7 @@ static struct option const options[] = { { "userpass", 1, NULL, 'O' }, { "data-file", 1, NULL, 1027 }, { "verify", 0, NULL, 1028 }, + { "stratum-keepalive", 0, NULL, 1029 }, { "version", 0, NULL, 'V' }, { 0, 0, 0, 0 } }; diff --git a/util.c b/util.c index 31b9270..a462bcc 100644 --- a/util.c +++ b/util.c @@ -1846,6 +1846,25 @@ out: return ret; } +bool stratum_suggest_difficulty( struct stratum_ctx *sctx, double diff ) +{ + char *s; + s = (char*) malloc( 80 ); + bool rc = true; + + // response is handled seperately, what ID? + sprintf( s, "{\"id\": 1, \"method\": \"mining.suggest_difficulty\", \"params\": [\"%f\"]}", diff ); + if ( !stratum_send_line( sctx, s ) ) + { + applog(LOG_WARNING,"stratum.suggest_difficulty send failed"); + rc = false; + } + free ( s ); + return rc; +} + + + /** * Extract bloc height L H... here len=3, height=0x1333e8 * "...0000000000ffffffff2703e83313062f503253482f043d61105408"