Skip to content

Commit

Permalink
limit per-core hashrate logs to 5 sec intervals
Browse files Browse the repository at this point in the history
tunable with --max-log-rate (when not using --quiet)
  • Loading branch information
tpruvot committed Jan 26, 2017
1 parent f6639ac commit 18cf11a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version 1.3.1 (WIP)
- Add timetravel algo
- Add --max-log-rate to limit per-core logs

Version 1.3 (Tanguy Pruvot)
- Add decred algo
Expand Down
12 changes: 10 additions & 2 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ bool use_syslog = false;
bool use_colors = true;
static bool opt_background = false;
bool opt_quiet = false;
int opt_maxlograte = 5;
bool opt_randomize = false;
static int opt_retries = -1;
static int opt_fail_pause = 10;
Expand Down Expand Up @@ -347,6 +348,7 @@ Options:\n\
-n, --nfactor neoscrypt N-Factor\n\
--coinbase-addr=ADDR payout address for solo mining\n\
--coinbase-sig=TEXT data to insert in the coinbase when possible\n\
--max-log-rate limit per-core hashrate logs (default: 5s)\n\
--no-longpoll disable long polling support\n\
--no-getwork disable getwork support\n\
--no-gbt disable getblocktemplate support\n\
Expand All @@ -357,7 +359,7 @@ Options:\n\
--no-color disable colored output\n\
-D, --debug enable debug output\n\
-P, --protocol-dump verbose dump of protocol-level activities\n\
--hide-diff display submitted block and net difficulty\n"
--hide-diff Hide submitted block and net difficulty\n"
#ifdef HAVE_SYSLOG_H
"\
-S, --syslog use system log for output messages\n"
Expand Down Expand Up @@ -425,6 +427,7 @@ static struct option const options[] = {
{ "scantime", 1, NULL, 's' },
{ "show-diff", 0, NULL, 1013 },
{ "hide-diff", 0, NULL, 1014 },
{ "max-log-rate", 1, NULL, 1019 },
#ifdef HAVE_SYSLOG_H
{ "syslog", 0, NULL, 'S' },
#endif
Expand Down Expand Up @@ -1862,6 +1865,7 @@ static void *miner_thread(void *userdata)
struct work work;
uint32_t max_nonce;
uint32_t end_nonce = 0xffffffffU / opt_n_threads * (thr_id + 1) - 0x20;
time_t tm_rate_log = 0;
time_t firstwork_time = 0;
unsigned char *scratchbuf = NULL;
char s[16];
Expand Down Expand Up @@ -2323,7 +2327,7 @@ static void *miner_thread(void *userdata)
hashes_done / (diff.tv_sec + diff.tv_usec * 1e-6);
pthread_mutex_unlock(&stats_lock);
}
if (!opt_quiet) {
if (!opt_quiet && (time(NULL) - tm_rate_log) > opt_maxlograte) {
switch(opt_algo) {
case ALGO_AXIOM:
case ALGO_CRYPTOLIGHT:
Expand All @@ -2338,6 +2342,7 @@ static void *miner_thread(void *userdata)
applog(LOG_INFO, "CPU #%d: %s kH/s", thr_id, s);
break;
}
tm_rate_log = time(NULL);
}
if (opt_benchmark && thr_id == opt_n_threads - 1) {
double hashrate = 0.;
Expand Down Expand Up @@ -3107,6 +3112,9 @@ void parse_arg(int key, char *arg)
use_syslog = true;
use_colors = false;
break;
case 1019: // max-log-rate
opt_maxlograte = atoi(arg);
break;
case 1020:
p = strstr(arg, "0x");
if (p)
Expand Down

0 comments on commit 18cf11a

Please sign in to comment.