Browse Source

Improve max nonce auto-adjustment with some basic algebra.

nfactor-troky
Jeff Garzik 14 years ago committed by Jeff Garzik
parent
commit
6818c6928a
  1. 13
      cpu-miner.c

13
cpu-miner.c

@ -500,6 +500,7 @@ static void *miner_thread(void *userdata)
struct work work __attribute__((aligned(128))); struct work work __attribute__((aligned(128)));
unsigned long hashes_done; unsigned long hashes_done;
struct timeval tv_start, tv_end, diff; struct timeval tv_start, tv_end, diff;
uint64_t max64;
bool rc; bool rc;
/* obtain new work from internal workio thread */ /* obtain new work from internal workio thread */
@ -576,14 +577,10 @@ static void *miner_thread(void *userdata)
hashmeter(thr_id, &diff, hashes_done); hashmeter(thr_id, &diff, hashes_done);
/* adjust max_nonce to meet target scan time */ /* adjust max_nonce to meet target scan time */
if (diff.tv_sec > (opt_scantime * 2)) max64 = ((uint64_t)hashes_done * opt_scantime) / diff.tv_sec;
max_nonce /= 2; /* large decrease */ if (max64 > 0xfffffffaULL)
else if ((diff.tv_sec > opt_scantime) && max64 = 0xfffffffaULL;
(max_nonce > 1500000)) max_nonce = max64;
max_nonce -= 1000000; /* small decrease */
else if ((diff.tv_sec < opt_scantime) &&
(max_nonce < 0xffffec76))
max_nonce += 100000; /* small increase */
/* if nonce found, submit work */ /* if nonce found, submit work */
if (rc && !submit_work(mythr, &work)) if (rc && !submit_work(mythr, &work))

Loading…
Cancel
Save