This commit is contained in:
Jay D Dee
2022-01-12 21:08:25 -05:00
parent 17ccbc328f
commit 8727d79182
7 changed files with 86 additions and 23 deletions

View File

@@ -65,6 +65,15 @@ If not what makes it happen or not happen?
Change Log 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 v3.19.3
Linux: Faster verthash (+25%), scryptn2 (+2%) when huge pages are available. Linux: Faster verthash (+25%), scryptn2 (+2%) when huge pages are available.

View File

@@ -87,17 +87,18 @@ int verthash_info_init(verthash_info_t* info, const char* file_name)
// Allocate data // Allocate data
info->data = (uint8_t *)malloc_hugepages( fileSize ); info->data = (uint8_t *)malloc_hugepages( fileSize );
if ( info->data ) 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 ); info->data = (uint8_t *)_mm_malloc( fileSize, 64 );
if ( !info->data ) if ( !info->data )
{ {
fclose( fileMiningData ); fclose( fileMiningData );
// Memory allocation fatal error. // Memory allocation fatal error.
return 2; return 2;
} }
}
// Load data // Load data
if ( !fread( info->data, fileSize, 1, fileMiningData ) ) if ( !fread( info->data, fileSize, 1, fileMiningData ) )

20
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # 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. # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='cpuminer-opt' PACKAGE_NAME='cpuminer-opt'
PACKAGE_TARNAME='cpuminer-opt' PACKAGE_TARNAME='cpuminer-opt'
PACKAGE_VERSION='3.19.3' PACKAGE_VERSION='3.19.4'
PACKAGE_STRING='cpuminer-opt 3.19.3' PACKAGE_STRING='cpuminer-opt 3.19.4'
PACKAGE_BUGREPORT='' PACKAGE_BUGREPORT=''
PACKAGE_URL='' 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. # 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. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF 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]... Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1404,7 +1404,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in 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 esac
cat <<\_ACEOF cat <<\_ACEOF
@@ -1509,7 +1509,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
cpuminer-opt configure 3.19.3 cpuminer-opt configure 3.19.4
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2012,7 +2012,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. 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 generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@@ -2993,7 +2993,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='cpuminer-opt' PACKAGE='cpuminer-opt'
VERSION='3.19.3' VERSION='3.19.4'
cat >>confdefs.h <<_ACEOF 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 # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" 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 generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@@ -6756,7 +6756,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ 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, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@@ -1,4 +1,4 @@
AC_INIT([cpuminer-opt], [3.19.3]) AC_INIT([cpuminer-opt], [3.19.4])
AC_PREREQ([2.59c]) AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM

View File

@@ -127,6 +127,10 @@ char *short_url = NULL;
char *coinbase_address; char *coinbase_address;
char *opt_data_file = NULL; char *opt_data_file = NULL;
bool opt_verify = false; 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 // pk_buffer_size is used as a version selector by b58 code, therefore
// it must be set correctly to work. // it must be set correctly to work.
@@ -2797,6 +2801,30 @@ static void *stratum_thread(void *userdata )
if ( stratum.new_job ) if ( stratum.new_job )
stratum_gen_work( &stratum, &g_work ); 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( stratum_socket_full( &stratum, opt_timeout ) ) )
{ {
if ( likely( s = stratum_recv_line( &stratum ) ) ) if ( likely( s = stratum_recv_line( &stratum ) ) )
@@ -2818,7 +2846,6 @@ static void *stratum_thread(void *userdata )
stratum_need_reset = true; stratum_need_reset = true;
// stratum_disconnect( &stratum ); // stratum_disconnect( &stratum );
} }
} // loop } // loop
out: out:
return NULL; 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_avx512 = cpu_has_avx512 && sw_has_avx512 && algo_has_avx512;
use_sha = cpu_has_sha && sw_has_sha && algo_has_sha; use_sha = cpu_has_sha && sw_has_sha && algo_has_sha;
use_vaes = cpu_has_vaes && sw_has_vaes && algo_has_vaes; use_vaes = cpu_has_vaes && sw_has_vaes && algo_has_vaes;
use_none = !( use_sse2 || use_aes || use_avx512 || use_avx2 || use_none = !( use_sse2 || use_sse42 || use_avx || use_aes || use_avx512
use_sha || use_vaes ); || use_avx2 || use_sha || use_vaes );
// Display best options // Display best options
printf( "\nStarting miner with" ); printf( "\nStarting miner with" );
@@ -3450,6 +3477,9 @@ void parse_arg(int key, char *arg )
case 1028: // verify case 1028: // verify
opt_verify = true; opt_verify = true;
break; break;
case 1029: // stratum-keepalive
opt_stratum_keepalive = true;
break;
case 'V': case 'V':
display_cpu_capability(); display_cpu_capability();
exit(0); exit(0);
@@ -3899,6 +3929,7 @@ int main(int argc, char *argv[])
gettimeofday( &last_submit_time, NULL ); gettimeofday( &last_submit_time, NULL );
memcpy( &five_min_start, &last_submit_time, sizeof (struct timeval) ); memcpy( &five_min_start, &last_submit_time, sizeof (struct timeval) );
memcpy( &session_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) ); memcpy( &total_hashes_time, &last_submit_time, sizeof (struct timeval) );
pthread_mutex_unlock( &stats_lock ); pthread_mutex_unlock( &stats_lock );

View File

@@ -466,6 +466,7 @@ void stratum_disconnect(struct stratum_ctx *sctx);
bool stratum_subscribe(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_authorize(struct stratum_ctx *sctx, const char *user, const char *pass);
bool stratum_handle_method(struct stratum_ctx *sctx, const char *s); 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; extern bool aes_ni_supported;
@@ -918,6 +919,7 @@ Options:\n\
-c, --config=FILE load a JSON-format configuration file\n\ -c, --config=FILE load a JSON-format configuration file\n\
--data-file=FILE path and name of data file\n\ --data-file=FILE path and name of data file\n\
--verify enable additional time consuming start up tests\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\ -V, --version display version and CPU information and exit\n\
-h, --help display this help text 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' }, { "userpass", 1, NULL, 'O' },
{ "data-file", 1, NULL, 1027 }, { "data-file", 1, NULL, 1027 },
{ "verify", 0, NULL, 1028 }, { "verify", 0, NULL, 1028 },
{ "stratum-keepalive", 0, NULL, 1029 },
{ "version", 0, NULL, 'V' }, { "version", 0, NULL, 'V' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };

19
util.c
View File

@@ -1846,6 +1846,25 @@ out:
return ret; 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 * Extract bloc height L H... here len=3, height=0x1333e8
* "...0000000000ffffffff2703e83313062f503253482f043d61105408" * "...0000000000ffffffff2703e83313062f503253482f043d61105408"