|
|
@@ -369,7 +369,7 @@ static void sharelog(const char*disposition, const struct work*work)
|
|
|
thr_id = work->thr_id;
|
|
|
cgpu = thr_info[thr_id].cgpu;
|
|
|
pool = work->pool;
|
|
|
- t = (unsigned long int)work->share_found_time;
|
|
|
+ t = (unsigned long int)(work->tv_work_found.tv_sec);
|
|
|
target = bin2hex(work->target, sizeof(work->target));
|
|
|
if (unlikely(!target)) {
|
|
|
applog(LOG_ERR, "sharelog target OOM");
|
|
|
@@ -2101,6 +2101,7 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub
|
|
|
struct pool *pool = work->pool;
|
|
|
int rolltime;
|
|
|
uint32_t *hash32;
|
|
|
+ struct timeval tv_submit, tv_submit_reply;
|
|
|
char hashshow[64+1] = "";
|
|
|
char worktime[200] = "";
|
|
|
|
|
|
@@ -2133,14 +2134,14 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub
|
|
|
|
|
|
applog(LOG_DEBUG, "DBG: sending %s submit RPC call: %s", pool->rpc_url, sd);
|
|
|
|
|
|
- gettimeofday((struct timeval *)&(work->tv_submit), NULL);
|
|
|
+ gettimeofday(&tv_submit, NULL);
|
|
|
/* issue JSON-RPC request */
|
|
|
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, s, false, false, &rolltime, pool, true);
|
|
|
|
|
|
free(s);
|
|
|
free(sd);
|
|
|
|
|
|
- gettimeofday((struct timeval *)&(work->tv_submit_reply), NULL);
|
|
|
+ gettimeofday(&tv_submit_reply, NULL);
|
|
|
if (unlikely(!val)) {
|
|
|
applog(LOG_INFO, "submit_upstream_work json_rpc_call failed");
|
|
|
if (!pool_tset(pool, &pool->submit_fail)) {
|
|
|
@@ -2164,24 +2165,39 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub
|
|
|
}
|
|
|
|
|
|
if (opt_worktime) {
|
|
|
+ char workclone[20];
|
|
|
+ struct tm *tm, tm_getwork, tm_submit_reply;
|
|
|
double getwork_time = tdiff((struct timeval *)&(work->tv_getwork_reply),
|
|
|
(struct timeval *)&(work->tv_getwork));
|
|
|
double getwork_to_work = tdiff((struct timeval *)&(work->tv_work_start),
|
|
|
(struct timeval *)&(work->tv_getwork_reply));
|
|
|
- double work_time = tdiff((struct timeval *)&(work->tv_work_finish),
|
|
|
+ double work_time = tdiff((struct timeval *)&(work->tv_work_found),
|
|
|
(struct timeval *)&(work->tv_work_start));
|
|
|
- double work_to_submit = tdiff((struct timeval *)&(work->tv_submit),
|
|
|
- (struct timeval *)&(work->tv_work_finish));
|
|
|
- double submit_time = tdiff((struct timeval *)&(work->tv_submit_reply),
|
|
|
- (struct timeval *)&(work->tv_submit));
|
|
|
- struct tm *tm = localtime(&(work->tv_submit_reply.tv_sec));
|
|
|
- sprintf(worktime, " <-%08lx.%08lx %c G:%1.3f (%1.3f) W:%1.3f (%1.3f) S:%1.3f R:%02d:%02d:%02d",
|
|
|
+ double work_to_submit = tdiff(&tv_submit,
|
|
|
+ (struct timeval *)&(work->tv_work_found));
|
|
|
+ double submit_time = tdiff(&tv_submit_reply, &tv_submit);
|
|
|
+
|
|
|
+ tm = localtime(&(work->tv_getwork.tv_sec));
|
|
|
+ memcpy(&tm_getwork, tm, sizeof(struct tm));
|
|
|
+ tm = localtime(&(tv_submit_reply.tv_sec));
|
|
|
+ memcpy(&tm_submit_reply, tm, sizeof(struct tm));
|
|
|
+
|
|
|
+ if (work->clone) {
|
|
|
+ sprintf(workclone, "C:%1.3f",
|
|
|
+ tdiff((struct timeval *)&(work->tv_cloned),
|
|
|
+ (struct timeval *)&(work->tv_getwork_reply)));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ strcpy(workclone, "O");
|
|
|
+
|
|
|
+ sprintf(worktime, " <-%08lx.%08lx M:%c G:%02d:%02d:%02d:%1.3f %s (%1.3f) W:%1.3f (%1.3f) S:%1.3f R:%02d:%02d:%02d",
|
|
|
(unsigned long)swab32(*(uint32_t *)&(work->data[28])),
|
|
|
(unsigned long)swab32(*(uint32_t *)&(work->data[24])),
|
|
|
- work->clone ? 'C' : 'O',
|
|
|
- getwork_time, getwork_to_work, work_time,
|
|
|
- work_to_submit, submit_time,
|
|
|
- tm->tm_hour, tm->tm_min, tm->tm_sec);
|
|
|
+ work->getwork_mode, tm_getwork.tm_hour, tm_getwork.tm_min,
|
|
|
+ tm_getwork.tm_sec, getwork_time, workclone,
|
|
|
+ getwork_to_work, work_time, work_to_submit, submit_time,
|
|
|
+ tm_submit_reply.tm_hour, tm_submit_reply.tm_min,
|
|
|
+ tm_submit_reply.tm_sec);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2369,6 +2385,9 @@ static void get_benchmark_work(struct work *work)
|
|
|
memcpy(work, &bench_block, min_size);
|
|
|
work->mandatory = true;
|
|
|
work->pool = pools[0];
|
|
|
+ gettimeofday(&(work->tv_getwork), NULL);
|
|
|
+ memcpy(&(work->tv_getwork_reply), &(work->tv_getwork), sizeof(struct timeval));
|
|
|
+ work->getwork_mode = GETWORK_MODE_BENCHMARK;
|
|
|
}
|
|
|
|
|
|
static char *prepare_rpc_req(struct work *work, enum pool_protocol proto, const char *lpid)
|
|
|
@@ -2493,6 +2512,7 @@ tryagain:
|
|
|
|
|
|
work->pool = pool;
|
|
|
work->longpoll = false;
|
|
|
+ work->getwork_mode = GETWORK_MODE_POOL;
|
|
|
total_getworks++;
|
|
|
pool->getwork_requested++;
|
|
|
|
|
|
@@ -2846,6 +2866,7 @@ static struct work *make_clone(struct work *work)
|
|
|
|
|
|
workcpy(work_clone, work);
|
|
|
work_clone->clone = true;
|
|
|
+ gettimeofday((struct timeval *)&(work_clone->tv_cloned), NULL);
|
|
|
work_clone->longpoll = false;
|
|
|
work_clone->mandatory = false;
|
|
|
/* Make cloned work appear slightly older to bias towards keeping the
|
|
|
@@ -4590,6 +4611,7 @@ static char *absolute_uri(char *uri, const char *ref)
|
|
|
|
|
|
static bool pool_active(struct pool *pool, bool pinging)
|
|
|
{
|
|
|
+ struct timeval tv_getwork, tv_getwork_reply;
|
|
|
bool ret = false;
|
|
|
json_t *val;
|
|
|
CURL *curl;
|
|
|
@@ -4614,8 +4636,10 @@ tryagain:
|
|
|
return false;
|
|
|
|
|
|
applog(LOG_INFO, "Testing pool %s", pool->rpc_url);
|
|
|
+ gettimeofday(&tv_getwork, NULL);
|
|
|
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req,
|
|
|
true, false, &rolltime, pool, false);
|
|
|
+ gettimeofday(&tv_getwork_reply, NULL);
|
|
|
|
|
|
if (val) {
|
|
|
bool rc;
|
|
|
@@ -4631,6 +4655,9 @@ tryagain:
|
|
|
pool->pool_no, pool->rpc_url);
|
|
|
work->pool = pool;
|
|
|
work->rolltime = rolltime;
|
|
|
+ memcpy(&(work->tv_getwork), &tv_getwork, sizeof(struct timeval));
|
|
|
+ memcpy(&(work->tv_getwork_reply), &tv_getwork_reply, sizeof(struct timeval));
|
|
|
+ work->getwork_mode = GETWORK_MODE_TESTPOOL;
|
|
|
applog(LOG_DEBUG, "Pushing pooltest work to base pool");
|
|
|
|
|
|
tq_push(thr_info[stage_thr_id].q, work);
|
|
|
@@ -4930,7 +4957,7 @@ out:
|
|
|
work->mined = true;
|
|
|
}
|
|
|
|
|
|
-bool submit_work_sync(struct thr_info *thr, const struct work *work_in)
|
|
|
+bool submit_work_sync(struct thr_info *thr, const struct work *work_in, struct timeval *tv_work_found)
|
|
|
{
|
|
|
struct workio_cmd *wc;
|
|
|
|
|
|
@@ -4945,7 +4972,8 @@ bool submit_work_sync(struct thr_info *thr, const struct work *work_in)
|
|
|
wc->cmd = WC_SUBMIT_WORK;
|
|
|
wc->thr = thr;
|
|
|
workcpy(wc->work, work_in);
|
|
|
- wc->work->share_found_time = time(NULL);
|
|
|
+ if (tv_work_found)
|
|
|
+ memcpy(&(wc->work->tv_work_found), tv_work_found, sizeof(struct timeval));
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing submit work to work thread");
|
|
|
|
|
|
@@ -5005,7 +5033,8 @@ bool test_nonce(struct work *work, uint32_t nonce, bool checktarget)
|
|
|
|
|
|
bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
|
|
|
{
|
|
|
- gettimeofday(&(work->tv_work_finish), NULL);
|
|
|
+ struct timeval tv_work_found;
|
|
|
+ gettimeofday(&tv_work_found, NULL);
|
|
|
|
|
|
total_diff1++;
|
|
|
thr->cgpu->diff1++;
|
|
|
@@ -5017,7 +5046,7 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
|
|
|
applog(LOG_INFO, "Pool %d share below target", work->pool->pool_no);
|
|
|
return true;
|
|
|
}
|
|
|
- return submit_work_sync(thr, work);
|
|
|
+ return submit_work_sync(thr, work, &tv_work_found);
|
|
|
}
|
|
|
|
|
|
static inline bool abandon_work(struct work *work, struct timeval *wdiff, uint64_t hashes)
|
|
|
@@ -5236,7 +5265,7 @@ enum {
|
|
|
};
|
|
|
|
|
|
/* Stage another work item from the work returned in a longpoll */
|
|
|
-static void convert_to_work(json_t *val, int rolltime, struct pool *pool, struct work *work)
|
|
|
+static void convert_to_work(json_t *val, int rolltime, struct pool *pool, struct work *work, struct timeval *tv_lp, struct timeval *tv_lp_reply)
|
|
|
{
|
|
|
bool rc;
|
|
|
|
|
|
@@ -5249,6 +5278,9 @@ static void convert_to_work(json_t *val, int rolltime, struct pool *pool, struct
|
|
|
work->pool = pool;
|
|
|
work->rolltime = rolltime;
|
|
|
work->longpoll = true;
|
|
|
+ memcpy(&(work->tv_getwork), tv_lp, sizeof(struct timeval));
|
|
|
+ memcpy(&(work->tv_getwork_reply), tv_lp_reply, sizeof(struct timeval));
|
|
|
+ work->getwork_mode = GETWORK_MODE_LP;
|
|
|
|
|
|
if (pool->enabled == POOL_REJECTING)
|
|
|
work->mandatory = true;
|
|
|
@@ -5324,7 +5356,7 @@ static void *longpoll_thread(void *userdata)
|
|
|
/* This *pool is the source of the actual longpoll, not the pool we've
|
|
|
* tied it to */
|
|
|
struct pool *pool = NULL;
|
|
|
- struct timeval start, end;
|
|
|
+ struct timeval start, reply, end;
|
|
|
CURL *curl = NULL;
|
|
|
int failures = 0;
|
|
|
int rolltime;
|
|
|
@@ -5381,13 +5413,16 @@ retry_pool:
|
|
|
val = json_rpc_call(curl, pool->lp_url, pool->rpc_userpass, rpc_req,
|
|
|
false, true, &rolltime, pool, false);
|
|
|
pool->lp_socket = CURL_SOCKET_BAD;
|
|
|
+
|
|
|
+ gettimeofday(&reply, NULL);
|
|
|
+
|
|
|
if (likely(val)) {
|
|
|
soval = json_object_get(json_object_get(val, "result"), "submitold");
|
|
|
if (soval)
|
|
|
pool->submit_old = json_is_true(soval);
|
|
|
else
|
|
|
pool->submit_old = false;
|
|
|
- convert_to_work(val, rolltime, pool, work);
|
|
|
+ convert_to_work(val, rolltime, pool, work, &start, &reply);
|
|
|
failures = 0;
|
|
|
json_decref(val);
|
|
|
} else {
|