Browse Source

Merge commit '796f390' into cgmerges

Conflicts:
	miner.c
	miner.h
Luke Dashjr 13 years ago
parent
commit
b226c06f08
4 changed files with 82 additions and 41 deletions
  1. 13 10
      README
  2. 2 2
      driver-cpu.c
  3. 56 21
      miner.c
  4. 11 8
      miner.h

+ 13 - 10
README

@@ -483,19 +483,22 @@ and pipe the output directly to that command.
 The WorkTime details 'debug' option adds details on the end of each line
 displayed for Accepted or Rejected work done. An example would be:
 
-  <-00000223.95214f4c O G:0.524 (97.672) W:4.910 (0.000) S:0.577 R:13:49:55
+ <-00000059.ed4834a3 M:X G:17:02:38:0.405 C:1.855 (2.995) W:3.440 (0.000) S:0.461 R:17:02:47
 
 The first 2 hex codes are the previous block hash, the rest are reported in
 seconds unless stated otherwise:
-The previous hash is followed by 'C' or 'O' if the work was cloned or original,
-G:n.nnn is how long the original getwork to the pool took, (m.mmm) is how long
-from the original getwork complete until work started, W:n.nnn is how long the
-work took to process until it was ready to submit, (m.mmm) is how long from
-ready to submit to actually doing the submit, this is usually 0.000 unless
-there was a problem with the first attempt at submitting the work, S:n.nnn
-is how long it took to submit the work and await the reply, R:hh:mm:ss is the
-actual time the work submit reply was received - so you can count back from
-that to work out each absolute time
+The previous hash is followed by the getwork mode used M:X where X is one of
+P:Pool, T:Test Pool, L:LP or B:Benchmark,
+then G:hh:mm:ss:n.nnn, which is when the getwork or LP was sent to the pool and
+the n.nnn is how long it took to reply,
+followed by 'O' on it's own if it is an original getwork, or 'C:n.nnn' if it was
+a clone with n.nnn stating how long after the work was recieved that it was cloned,
+(m.mmm) is how long from when the original work was received until work started,
+W:n.nnn is how long the work took to process until it was ready to submit,
+(m.mmm) is how long from ready to submit to actually doing the submit, this is
+usually 0.000 unless there was a problem with submitting the work,
+S:n.nnn is how long it took to submit the completed work and await the reply,
+R:hh:mm:ss is the actual time the work submit reply was received
 
 If you start BFGMiner with the --sharelog option, you can get detailed
 information for each share found. The argument to the option may be "-" for

+ 2 - 2
driver-cpu.c

@@ -75,7 +75,7 @@ static inline void affine_to_cpu(__maybe_unused int id, __maybe_unused int cpu)
 
 
 /* TODO: resolve externals */
-extern bool submit_work_sync(struct thr_info *thr, const struct work *work_in);
+extern bool submit_work_sync(struct thr_info *thr, const struct work *work_in, struct timeval *tv);
 extern char *set_int_range(const char *arg, int *i, int min, int max);
 extern int dev_from_id(int thr_id);
 
@@ -834,7 +834,7 @@ CPUSearch:
 	/* if nonce found, submit work */
 	if (unlikely(rc)) {
 		applog(LOG_DEBUG, "CPU %d found something?", dev_from_id(thr_id));
-		if (unlikely(!submit_work_sync(thr, work))) {
+		if (unlikely(!submit_work_sync(thr, work, NULL))) {
 			applog(LOG_ERR, "Failed to submit_work_sync in miner_thread %d", thr_id);
 		}
 		work->blk.nonce = last_nonce + 1;

+ 56 - 21
miner.c

@@ -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 {

+ 11 - 8
miner.h

@@ -872,6 +872,11 @@ struct pool {
 	struct cgminer_pool_stats cgminer_pool_stats;
 };
 
+#define GETWORK_MODE_TESTPOOL 'T'
+#define GETWORK_MODE_POOL 'P'
+#define GETWORK_MODE_LP 'L'
+#define GETWORK_MODE_BENCHMARK 'B'
+
 struct work {
 	unsigned char	data[128];
 	unsigned char	hash1[64];
@@ -906,18 +911,16 @@ struct work {
 	
 	float		difficulty;
 
-	time_t share_found_time;
-
 	blktemplate_t	*tmpl;
 	int		*tmpl_refcount;
 	unsigned int	dataid;
 
-	struct timeval tv_getwork;
-	struct timeval tv_getwork_reply;
-	struct timeval tv_work_start;
-	struct timeval tv_work_finish;
-	struct timeval tv_submit;
-	struct timeval tv_submit_reply;
+	struct timeval	tv_getwork;
+	struct timeval	tv_getwork_reply;
+	struct timeval	tv_cloned;
+	struct timeval	tv_work_start;
+	struct timeval	tv_work_found;
+	char		getwork_mode;
 };
 
 extern void get_datestamp(char *, struct timeval *);