Work out a rolling average getwork delay stored in pool_stats.
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
diff --git a/api.c b/api.c
index 7eb684d..078c157 100644
--- a/api.c
+++ b/api.c
@@ -2114,11 +2114,12 @@ static int itemstats(int i, char *id, struct cgminer_stats *stats, struct cgmine
if (pool_stats) {
sprintf(buf, isjson
? ",\"Pool Calls\":%d,\"Pool Attempts\":%d,\"Pool Wait\":%ld.%06ld,\"Pool Max\":%ld.%06ld,\"Pool Min\":%ld.%06ld"
- : ",Pool Calls=%d,Pool Attempts=%d,Pool Wait=%ld.%06ld,Pool Max=%ld.%06ld,Pool Min=%ld.%06ld",
+ : ",Pool Calls=%d,Pool Attempts=%d,Pool Wait=%ld.%06ld,Pool Max=%ld.%06ld,Pool Min=%ld.%06ld,Pool Av=%f",
pool_stats->getwork_calls, pool_stats->getwork_attempts,
pool_stats->getwork_wait.tv_sec, pool_stats->getwork_wait.tv_usec,
pool_stats->getwork_wait_max.tv_sec, pool_stats->getwork_wait_max.tv_usec,
- pool_stats->getwork_wait_min.tv_sec, pool_stats->getwork_wait_min.tv_usec);
+ pool_stats->getwork_wait_min.tv_sec, pool_stats->getwork_wait_min.tv_usec,
+ pool_stats->getwork_wait_rolling);
strcat(io_buffer, buf);
}
diff --git a/cgminer.c b/cgminer.c
index 9384a16..c7a6d39 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1856,13 +1856,11 @@ retry:
if (!rc && retries < 3)
goto retry;
- work->pool = pool;
- work->longpoll = false;
- total_getworks++;
- pool->getwork_requested++;
-
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;
+ pool_stats->getwork_wait_rolling /= 1.63;
+
timeradd(&tv_elapsed, &(pool_stats->getwork_wait), &(pool_stats->getwork_wait));
if (timercmp(&tv_elapsed, &(pool_stats->getwork_wait_max), >)) {
pool_stats->getwork_wait_max.tv_sec = tv_elapsed.tv_sec;
@@ -1874,6 +1872,11 @@ retry:
}
pool_stats->getwork_calls++;
+ work->pool = pool;
+ work->longpoll = false;
+ total_getworks++;
+ pool->getwork_requested++;
+
json_decref(val);
out:
diff --git a/miner.h b/miner.h
index b1840e9..9eb1b6d 100644
--- a/miner.h
+++ b/miner.h
@@ -298,6 +298,7 @@ struct cgminer_pool_stats {
struct timeval getwork_wait;
struct timeval getwork_wait_max;
struct timeval getwork_wait_min;
+ double getwork_wait_rolling;
};
struct cgpu_info {