Version 2.1.2
- Do not submit work that is known to be stale - Allow miner threads to ask for new work if the current one is at least 45 seconds old and long polling is enabled - Refresh work when long polling times out - Modify x86-64 code to make it compatible with older versions of binutils
This commit is contained in:
parent
1628975469
commit
d26b0d8b81
7 changed files with 46 additions and 30 deletions
9
NEWS
9
NEWS
|
@ -1,3 +1,12 @@
|
||||||
|
Version 2.1.2 - Jan 26, 2012
|
||||||
|
|
||||||
|
- Do not submit work that is known to be stale
|
||||||
|
- Allow miner threads to ask for new work if the current one is at least
|
||||||
|
45 seconds old and long polling is enabled
|
||||||
|
- Refresh work when long polling times out
|
||||||
|
- Fix minor speed regression
|
||||||
|
- Modify x86-64 code to make it compatible with older versions of binutils
|
||||||
|
|
||||||
Version 2.1.1 - Jan 20, 2012
|
Version 2.1.1 - Jan 20, 2012
|
||||||
|
|
||||||
- Handle network errors properly
|
- Handle network errors properly
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
AC_INIT([cpuminer], [2.1.1])
|
AC_INIT([cpuminer], [2.1.2])
|
||||||
|
|
||||||
AC_PREREQ(2.52)
|
AC_PREREQ(2.52)
|
||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
|
|
18
cpu-miner.c
18
cpu-miner.c
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#define PROGRAM_NAME "minerd"
|
#define PROGRAM_NAME "minerd"
|
||||||
#define DEF_RPC_URL "http://127.0.0.1:9332/"
|
#define DEF_RPC_URL "http://127.0.0.1:9332/"
|
||||||
|
#define LP_SCANTIME 60
|
||||||
|
|
||||||
#ifdef __linux /* Linux specific policy and affinity management */
|
#ifdef __linux /* Linux specific policy and affinity management */
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
@ -279,6 +280,10 @@ static bool submit_upstream_work(CURL *curl, const struct work *work)
|
||||||
int i;
|
int i;
|
||||||
bool rc = false;
|
bool rc = false;
|
||||||
|
|
||||||
|
/* pass if the previous hash is not the current previous hash */
|
||||||
|
if (memcmp(work->data + 4, g_work.data + 4, 32))
|
||||||
|
return true;
|
||||||
|
|
||||||
/* build hex string */
|
/* build hex string */
|
||||||
hexstr = bin2hex(work->data, sizeof(work->data));
|
hexstr = bin2hex(work->data, sizeof(work->data));
|
||||||
if (unlikely(!hexstr)) {
|
if (unlikely(!hexstr)) {
|
||||||
|
@ -548,7 +553,7 @@ static void *miner_thread(void *userdata)
|
||||||
|
|
||||||
/* obtain new work from internal workio thread */
|
/* obtain new work from internal workio thread */
|
||||||
pthread_mutex_lock(&g_work_lock);
|
pthread_mutex_lock(&g_work_lock);
|
||||||
if (!have_longpoll || time(NULL) >= g_work_time + opt_scantime) {
|
if (!have_longpoll || time(NULL) >= g_work_time + LP_SCANTIME*3/4) {
|
||||||
if (unlikely(!get_work(mythr, &g_work))) {
|
if (unlikely(!get_work(mythr, &g_work))) {
|
||||||
applog(LOG_ERR, "work retrieval failed, exiting "
|
applog(LOG_ERR, "work retrieval failed, exiting "
|
||||||
"mining thread %d", mythr->id);
|
"mining thread %d", mythr->id);
|
||||||
|
@ -567,8 +572,9 @@ static void *miner_thread(void *userdata)
|
||||||
work_restart[thr_id].restart = 0;
|
work_restart[thr_id].restart = 0;
|
||||||
|
|
||||||
/* adjust max_nonce to meet target scan time */
|
/* adjust max_nonce to meet target scan time */
|
||||||
max64 = (g_work_time + opt_scantime - time(NULL)) *
|
max64 = g_work_time + (have_longpoll ? LP_SCANTIME : opt_scantime)
|
||||||
(int64_t)thr_hashrates[thr_id];
|
- time(NULL);
|
||||||
|
max64 *= thr_hashrates[thr_id];
|
||||||
if (max64 <= 0)
|
if (max64 <= 0)
|
||||||
max64 = 0xfffLL;
|
max64 = 0xfffLL;
|
||||||
if (next_nonce + max64 > 0xfffffffeLL)
|
if (next_nonce + max64 > 0xfffffffeLL)
|
||||||
|
@ -676,14 +682,16 @@ static void *longpoll_thread(void *userdata)
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&g_work_lock);
|
pthread_mutex_unlock(&g_work_lock);
|
||||||
json_decref(val);
|
json_decref(val);
|
||||||
} else if (err != CURLE_OPERATION_TIMEDOUT) {
|
} else {
|
||||||
pthread_mutex_lock(&g_work_lock);
|
pthread_mutex_lock(&g_work_lock);
|
||||||
g_work_time -= opt_scantime;
|
g_work_time -= LP_SCANTIME;
|
||||||
pthread_mutex_unlock(&g_work_lock);
|
pthread_mutex_unlock(&g_work_lock);
|
||||||
restart_threads();
|
restart_threads();
|
||||||
|
if (err != CURLE_OPERATION_TIMEDOUT) {
|
||||||
sleep(opt_fail_pause);
|
sleep(opt_fail_pause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(hdr_path);
|
free(hdr_path);
|
||||||
|
|
1
miner.h
1
miner.h
|
@ -137,7 +137,6 @@ timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
|
||||||
|
|
||||||
extern bool fulltest(const unsigned char *hash, const unsigned char *target);
|
extern bool fulltest(const unsigned char *hash, const unsigned char *target);
|
||||||
|
|
||||||
extern int opt_scantime;
|
|
||||||
extern int opt_timeout;
|
extern int opt_timeout;
|
||||||
extern bool want_longpoll;
|
extern bool want_longpoll;
|
||||||
extern bool have_longpoll;
|
extern bool have_longpoll;
|
||||||
|
|
37
scrypt-x64.S
37
scrypt-x64.S
|
@ -1693,22 +1693,23 @@ scrypt_core_3way_loop1:
|
||||||
cmpq %rax, %rbp
|
cmpq %rax, %rbp
|
||||||
jne scrypt_core_3way_loop1
|
jne scrypt_core_3way_loop1
|
||||||
|
|
||||||
movq $1024, %rax
|
movq $1024, %r8
|
||||||
|
.align 16
|
||||||
scrypt_core_3way_loop2:
|
scrypt_core_3way_loop2:
|
||||||
movl 64(%rsp), %ebp
|
movl 64(%rsp), %ebp
|
||||||
andl $1023, %ebp
|
andl $1023, %ebp
|
||||||
leal (%ebp, %ebp, 2), %ebp
|
leaq (%rbp, %rbp, 2), %rbp
|
||||||
shll $7, %ebp
|
|
||||||
movl 128+64(%rsp), %ebx
|
movl 128+64(%rsp), %ebx
|
||||||
|
shll $7, %ebp
|
||||||
|
movl 256+64(%rsp), %eax
|
||||||
andl $1023, %ebx
|
andl $1023, %ebx
|
||||||
leal (%ebx, %ebx, 2), %ebx
|
leaq (%rbx, %rbx, 2), %rbx
|
||||||
shll $7, %ebx
|
shll $7, %ebx
|
||||||
|
shll $7, %eax
|
||||||
addl $128, %ebx
|
addl $128, %ebx
|
||||||
movl 256+64(%rsp), %r8d
|
andl $131071, %eax
|
||||||
andl $1023, %r8d
|
leaq (%rax, %rax, 2), %rax
|
||||||
leal (%r8d, %r8d, 2), %r8d
|
addl $256, %eax
|
||||||
shll $7, %r8d
|
|
||||||
addl $256, %r8d
|
|
||||||
movdqa 0(%rsp), %xmm0
|
movdqa 0(%rsp), %xmm0
|
||||||
movdqa 16(%rsp), %xmm1
|
movdqa 16(%rsp), %xmm1
|
||||||
movdqa 32(%rsp), %xmm2
|
movdqa 32(%rsp), %xmm2
|
||||||
|
@ -1729,10 +1730,10 @@ scrypt_core_3way_loop2:
|
||||||
pxor 16(%rcx, %rbx), %xmm9
|
pxor 16(%rcx, %rbx), %xmm9
|
||||||
pxor 32(%rcx, %rbx), %xmm10
|
pxor 32(%rcx, %rbx), %xmm10
|
||||||
pxor 48(%rcx, %rbx), %xmm11
|
pxor 48(%rcx, %rbx), %xmm11
|
||||||
pxor 0(%rcx, %r8), %xmm12
|
pxor 0(%rcx, %rax), %xmm12
|
||||||
pxor 16(%rcx, %r8), %xmm13
|
pxor 16(%rcx, %rax), %xmm13
|
||||||
pxor 32(%rcx, %r8), %xmm14
|
pxor 32(%rcx, %rax), %xmm14
|
||||||
pxor 48(%rcx, %r8), %xmm15
|
pxor 48(%rcx, %rax), %xmm15
|
||||||
|
|
||||||
pxor 64(%rsp), %xmm0
|
pxor 64(%rsp), %xmm0
|
||||||
pxor 80(%rsp), %xmm1
|
pxor 80(%rsp), %xmm1
|
||||||
|
@ -1792,10 +1793,10 @@ scrypt_core_3way_loop2:
|
||||||
pxor 80(%rcx, %rbx), %xmm9
|
pxor 80(%rcx, %rbx), %xmm9
|
||||||
pxor 96(%rcx, %rbx), %xmm10
|
pxor 96(%rcx, %rbx), %xmm10
|
||||||
pxor 112(%rcx, %rbx), %xmm11
|
pxor 112(%rcx, %rbx), %xmm11
|
||||||
pxor 64(%rcx, %r8), %xmm12
|
pxor 64(%rcx, %rax), %xmm12
|
||||||
pxor 80(%rcx, %r8), %xmm13
|
pxor 80(%rcx, %rax), %xmm13
|
||||||
pxor 96(%rcx, %r8), %xmm14
|
pxor 96(%rcx, %rax), %xmm14
|
||||||
pxor 112(%rcx, %r8), %xmm15
|
pxor 112(%rcx, %rax), %xmm15
|
||||||
pxor 64(%rsp), %xmm0
|
pxor 64(%rsp), %xmm0
|
||||||
pxor 80(%rsp), %xmm1
|
pxor 80(%rsp), %xmm1
|
||||||
pxor 96(%rsp), %xmm2
|
pxor 96(%rsp), %xmm2
|
||||||
|
@ -1846,7 +1847,7 @@ scrypt_core_3way_loop2:
|
||||||
movdqa %xmm14, 256+96(%rsp)
|
movdqa %xmm14, 256+96(%rsp)
|
||||||
movdqa %xmm15, 256+112(%rsp)
|
movdqa %xmm15, 256+112(%rsp)
|
||||||
|
|
||||||
subq $1, %rax
|
subq $1, %r8
|
||||||
ja scrypt_core_3way_loop2
|
ja scrypt_core_3way_loop2
|
||||||
|
|
||||||
scrypt_shuffle %rsp, 0, %rdi, 0
|
scrypt_shuffle %rsp, 0, %rdi, 0
|
||||||
|
|
6
scrypt.c
6
scrypt.c
|
@ -542,7 +542,7 @@ int scanhash_scrypt(int thr_id, unsigned char *pdata, unsigned char *scratchbuf,
|
||||||
if (throughput >= 3 && n <= max_nonce) {
|
if (throughput >= 3 && n <= max_nonce) {
|
||||||
data3[19] = n++;
|
data3[19] = n++;
|
||||||
scrypt_1024_1_1_256_sp_3way(data, data2, data3, hash, hash2, hash3, scratchbuf);
|
scrypt_1024_1_1_256_sp_3way(data, data2, data3, hash, hash2, hash3, scratchbuf);
|
||||||
if (hash3[7] < Htarg || hash3[7] == Htarg && test_hash(hash3, (uint32_t *)ptarget)) {
|
if (hash3[7] < Htarg || (hash3[7] == Htarg && test_hash(hash3, (uint32_t *)ptarget))) {
|
||||||
be32enc(&((uint32_t *)pdata)[19], data3[19]);
|
be32enc(&((uint32_t *)pdata)[19], data3[19]);
|
||||||
*next_nonce = n;
|
*next_nonce = n;
|
||||||
*hashes_done = n - first_nonce;
|
*hashes_done = n - first_nonce;
|
||||||
|
@ -551,7 +551,7 @@ int scanhash_scrypt(int thr_id, unsigned char *pdata, unsigned char *scratchbuf,
|
||||||
} else {
|
} else {
|
||||||
scrypt_1024_1_1_256_sp_2way(data, data2, hash, hash2, scratchbuf);
|
scrypt_1024_1_1_256_sp_2way(data, data2, hash, hash2, scratchbuf);
|
||||||
}
|
}
|
||||||
if (hash2[7] < Htarg || hash2[7] == Htarg && test_hash(hash2, (uint32_t *)ptarget)) {
|
if (hash2[7] < Htarg || (hash2[7] == Htarg && test_hash(hash2, (uint32_t *)ptarget))) {
|
||||||
be32enc(&((uint32_t *)pdata)[19], data2[19]);
|
be32enc(&((uint32_t *)pdata)[19], data2[19]);
|
||||||
*next_nonce = n;
|
*next_nonce = n;
|
||||||
*hashes_done = n - first_nonce;
|
*hashes_done = n - first_nonce;
|
||||||
|
@ -563,7 +563,7 @@ int scanhash_scrypt(int thr_id, unsigned char *pdata, unsigned char *scratchbuf,
|
||||||
#else
|
#else
|
||||||
scrypt_1024_1_1_256_sp(data, hash, scratchbuf);
|
scrypt_1024_1_1_256_sp(data, hash, scratchbuf);
|
||||||
#endif
|
#endif
|
||||||
if (hash[7] < Htarg || hash[7] == Htarg && test_hash(hash, (uint32_t *)ptarget)) {
|
if (hash[7] < Htarg || (hash[7] == Htarg && test_hash(hash, (uint32_t *)ptarget))) {
|
||||||
be32enc(&((uint32_t *)pdata)[19], data[19]);
|
be32enc(&((uint32_t *)pdata)[19], data[19]);
|
||||||
*next_nonce = n;
|
*next_nonce = n;
|
||||||
*hashes_done = n - first_nonce;
|
*hashes_done = n - first_nonce;
|
||||||
|
|
1
util.c
1
util.c
|
@ -277,7 +277,6 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
||||||
/* If X-Long-Polling was found, activate long polling */
|
/* If X-Long-Polling was found, activate long polling */
|
||||||
if (hi.lp_path) {
|
if (hi.lp_path) {
|
||||||
have_longpoll = true;
|
have_longpoll = true;
|
||||||
opt_scantime = 60;
|
|
||||||
tq_push(thr_info[longpoll_thr_id].q, hi.lp_path);
|
tq_push(thr_info[longpoll_thr_id].q, hi.lp_path);
|
||||||
} else
|
} else
|
||||||
free(hi.lp_path);
|
free(hi.lp_path);
|
||||||
|
|
Loading…
Reference in a new issue