Queue requests for getwork regardless and test whether we should send for a getwork from the getwork thread itself.
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
diff --git a/cgminer.c b/cgminer.c
index 21b9e3e..389effb 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -70,7 +70,7 @@ struct workio_cmd {
enum workio_commands cmd;
struct thr_info *thr;
struct work *work;
- bool lagging;
+ bool needed;
};
struct strategies strategies[] = {
@@ -1933,7 +1933,7 @@ static inline struct pool *select_pool(bool lagging)
cp = current_pool();
- if (pool_strategy != POOL_LOADBALANCE && !lagging)
+ if (pool_strategy != POOL_LOADBALANCE && (!lagging || opt_fail_only))
pool = cp;
else
pool = NULL;
@@ -1997,6 +1997,8 @@ retry:
if (!rc && retries < 3)
goto retry;
+ pool->currently_rolling = !!work->rolltime;
+
gettimeofday(&tv_end, NULL);
timersub(&tv_end, &tv_start, &tv_elapsed);
pool_stats->getwork_wait_rolling += ((double)tv_elapsed.tv_sec + ((double)tv_elapsed.tv_usec / 1000000)) * 0.63;
@@ -2285,10 +2287,19 @@ static int global_queued(void)
return ret;
}
-static bool enough_work(void)
+static void *get_work_thread(void *userdata)
{
+ struct workio_cmd *wc = (struct workio_cmd *)userdata;
int cq, cs, ts, tq, maxq = opt_queue + mining_threads;
struct pool *pool = current_pool();
+ struct curl_ent *ce = NULL;
+ struct work *ret_work;
+ bool lagging = false;
+ int failures = 0;
+
+ pthread_detach(pthread_self());
+
+ applog(LOG_DEBUG, "Creating extra get work thread");
mutex_lock(&qd_lock);
cq = __pool_queued(pool);
@@ -2300,27 +2311,9 @@ static bool enough_work(void)
ts = __total_staged();
mutex_unlock(stgd_lock);
- if (((cs || cq >= opt_queue) && ts >= maxq) ||
- ((cs || cq) && tq >= maxq))
- return true;
- return false;
-}
-
-/* ce and pool may appear uninitialised at push_curl_entry, but they're always
- * set when we don't have opt_benchmark enabled */
-static void *get_work_thread(void *userdata)
-{
- struct workio_cmd *wc = (struct workio_cmd *)userdata;
- struct pool * uninitialised_var(pool);
- struct curl_ent *ce = NULL;
- struct work *ret_work;
- int failures = 0;
-
- pthread_detach(pthread_self());
-
- applog(LOG_DEBUG, "Creating extra get work thread");
-
- if (!wc->lagging && enough_work())
+ if (!ts)
+ lagging = true;
+ else if (((cs || cq >= opt_queue) && ts >= maxq) || ((cs || cq) && tq >= maxq))
goto out;
ret_work = make_work();
@@ -2332,7 +2325,7 @@ static void *get_work_thread(void *userdata)
if (opt_benchmark)
get_benchmark_work(ret_work);
else {
- pool = ret_work->pool = select_pool(wc->lagging);
+ pool = ret_work->pool = select_pool(lagging);
inc_queued(pool);
ce = pop_curl_entry(pool);
@@ -3820,33 +3813,7 @@ static void pool_resus(struct pool *pool)
bool queue_request(struct thr_info *thr, bool needed)
{
- int cq, cs, ts, tq, maxq = opt_queue + mining_threads;
- struct pool *pool = current_pool();
struct workio_cmd *wc;
- bool lag = false;
-
- mutex_lock(&qd_lock);
- cq = __pool_queued(pool);
- tq = __global_queued();
- mutex_unlock(&qd_lock);
-
- mutex_lock(stgd_lock);
- cs = __pool_staged(pool);
- ts = __total_staged();
- mutex_unlock(stgd_lock);
-
- if (needed && cq >= maxq && !ts && !opt_fail_only) {
- /* If we're queueing work faster than we can stage it, consider
- * the system lagging and allow work to be gathered from
- * another pool if possible */
- lag = true;
- } else {
- /* Test to make sure we have enough work for pools without rolltime
- * and enough original work for pools with rolltime */
- if (((cs || cq >= opt_queue) && ts >= maxq) ||
- ((cs || cq) && tq >= maxq))
- return true;
- }
/* fill out work request message */
wc = calloc(1, sizeof(*wc));
@@ -3857,7 +3824,7 @@ bool queue_request(struct thr_info *thr, bool needed)
wc->cmd = WC_GET_WORK;
wc->thr = thr;
- wc->lagging = lag;
+ wc->needed = needed;
applog(LOG_DEBUG, "Queueing getwork request to work thread");
diff --git a/miner.h b/miner.h
index f87612a..f3e51ed 100644
--- a/miner.h
+++ b/miner.h
@@ -735,6 +735,7 @@ struct pool {
bool submit_old;
bool removed;
bool lp_started;
+ bool currently_rolling;
char *hdr_path;
char *lp_url;