Skip to content

Commit

Permalink
v3.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JayDDee committed Jan 13, 2022
1 parent 17ccbc3 commit 8727d79
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 22 deletions.
9 changes: 9 additions & 0 deletions RELEASE_NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 8 additions & 7 deletions algo/verthash/Verthash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
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
Expand Down
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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=''

Expand Down Expand Up @@ -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]...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 $@
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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\\"
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -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
Expand Down
39 changes: 35 additions & 4 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ) ) )
Expand All @@ -2818,7 +2846,6 @@ static void *stratum_thread(void *userdata )
stratum_need_reset = true;
// stratum_disconnect( &stratum );
}

} // loop
out:
return NULL;
Expand Down Expand Up @@ -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" );
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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 );

Expand Down
3 changes: 3 additions & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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\
";
Expand Down Expand Up @@ -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 }
};
Expand Down
19 changes: 19 additions & 0 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,25 @@ bool stratum_authorize(struct stratum_ctx *sctx, const char *user, const char *p
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"
Expand Down

0 comments on commit 8727d79

Please sign in to comment.