Don't keep rolling work right up to the expire= cut off. Use 2/3 of the time between the scantime and the expiry as cutoff for reusing work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/cgminer.c b/cgminer.c
index 774c5f6..69181b0 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2166,22 +2166,26 @@ static bool stale_work(struct work *work, bool share)
if (work->mandatory)
return false;
- if (share)
- work_expiry = opt_expiry;
- else if (work->rolltime)
- work_expiry = work->rolltime;
- else
- work_expiry = opt_scantime;
+ if (share) {
+ if (work->rolltime)
+ work_expiry = work->rolltime;
+ else
+ work_expiry = opt_expiry;
+ } else {
+ /* Don't keep rolling work right up to the expiration */
+ if (work->rolltime > opt_scantime)
+ work_expiry = (work->rolltime - opt_scantime) * 2 / 3 + opt_scantime;
+ else /* Shouldn't happen unless someone increases scantime */
+ work_expiry = opt_scantime;
+ }
+
pool = work->pool;
/* Factor in the average getwork delay of this pool, rounding it up to
* the nearest second */
getwork_delay = pool->cgminer_pool_stats.getwork_wait_rolling * 5 + 1;
- if (!share) {
- work_expiry -= getwork_delay;
- if (unlikely(work_expiry < 5))
- work_expiry = 5;
- } else
- work_expiry += getwork_delay;
+ work_expiry -= getwork_delay;
+ if (unlikely(work_expiry < 5))
+ work_expiry = 5;
gettimeofday(&now, NULL);
if ((now.tv_sec - work->tv_staged.tv_sec) >= work_expiry)