From 55f7c1498247c4d3facae087933bf6dde7484032 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 16 Aug 2012 10:55:57 +1000 Subject: [PATCH] Grab clones from hashlist wherever possible first. --- cgminer.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cgminer.c b/cgminer.c index affa56f6..cec02ee7 100644 --- a/cgminer.c +++ b/cgminer.c @@ -3957,15 +3957,24 @@ static bool queue_request(struct thr_info *thr, bool needed) static struct work *hash_pop(const struct timespec *abstime) { - struct work *work = NULL; - int rc = 0; + struct work *work = NULL, *tmp; + int rc = 0, hc; mutex_lock(stgd_lock); while (!getq->frozen && !HASH_COUNT(staged_work) && !rc) rc = pthread_cond_timedwait(&getq->cond, stgd_lock, abstime); - if (HASH_COUNT(staged_work)) { - work = staged_work; + hc = HASH_COUNT(staged_work); + + if (likely(hc)) { + /* Find clone work if possible, to allow masters to be reused */ + if (hc > staged_rollable) { + HASH_ITER(hh, staged_work, work, tmp) { + if (!work_rollable(work)) + break; + } + } else + work = staged_work; HASH_DEL(staged_work, work); work->pool->staged--; if (work_rollable(work)) @@ -4110,7 +4119,6 @@ retry: pool_resus(pool); } - work_heap = clone_work(work_heap); memcpy(work, work_heap, sizeof(struct work)); free_work(work_heap);