Browse Source

Merge branch 'submitthr' into bfgminer

Conflicts:
	miner.c
Luke Dashjr 13 years ago
parent
commit
d24878e9cb
2 changed files with 47 additions and 3 deletions
  1. 1 0
      README
  2. 46 3
      miner.c

+ 1 - 0
README

@@ -163,6 +163,7 @@ Options for both config file and command line:
 --sharelog <arg>    Append share log to file
 --sharelog <arg>    Append share log to file
 --shares <arg>      Quit after mining N shares (default: unlimited)
 --shares <arg>      Quit after mining N shares (default: unlimited)
 --socks-proxy <arg> Set socks4 proxy (host:port)
 --socks-proxy <arg> Set socks4 proxy (host:port)
+--submit-threads    Maximum number of share submission threads (default: 64)
 --syslog            Use system log for output messages (default: standard error)
 --syslog            Use system log for output messages (default: standard error)
 --temp-cutoff <arg> Temperature where a device will be automatically disabled, one value or comma separated list (default: 95)
 --temp-cutoff <arg> Temperature where a device will be automatically disabled, one value or comma separated list (default: 95)
 --text-only|-T      Disable ncurses formatted screen output
 --text-only|-T      Disable ncurses formatted screen output

+ 46 - 3
miner.c

@@ -71,6 +71,8 @@ struct workio_cmd {
 	struct thr_info		*thr;
 	struct thr_info		*thr;
 	struct work		*work;
 	struct work		*work;
 	bool			lagging;
 	bool			lagging;
+
+	struct list_head list;
 };
 };
 
 
 struct strategies strategies[] = {
 struct strategies strategies[] = {
@@ -134,6 +136,7 @@ bool use_curses;
 #endif
 #endif
 static bool opt_submit_stale = true;
 static bool opt_submit_stale = true;
 static int opt_shares;
 static int opt_shares;
+static int opt_submit_threads = 0x40;
 static bool opt_fail_only;
 static bool opt_fail_only;
 bool opt_autofan;
 bool opt_autofan;
 bool opt_autoengine;
 bool opt_autoengine;
@@ -190,6 +193,10 @@ static struct timeval miner_started;
 
 
 pthread_mutex_t control_lock;
 pthread_mutex_t control_lock;
 
 
+static pthread_mutex_t submitting_lock;
+static int submitting;
+static struct list_head submit_waiting;
+
 int hw_errors;
 int hw_errors;
 int total_accepted, total_rejected;
 int total_accepted, total_rejected;
 float total_accepted_weighed;
 float total_accepted_weighed;
@@ -998,6 +1005,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITHOUT_ARG("--submit-stale",
 	OPT_WITHOUT_ARG("--submit-stale",
 			opt_set_bool, &opt_submit_stale,
 			opt_set_bool, &opt_submit_stale,
 	                opt_hidden),
 	                opt_hidden),
+	OPT_WITHOUT_ARG("--submit-threads",
+	                opt_set_intval, &opt_submit_threads,
+	                "Maximum number of share submission threads (default: 64)"),
 #ifdef HAVE_SYSLOG_H
 #ifdef HAVE_SYSLOG_H
 	OPT_WITHOUT_ARG("--syslog",
 	OPT_WITHOUT_ARG("--syslog",
 			opt_set_bool, &use_syslog,
 			opt_set_bool, &use_syslog,
@@ -2612,16 +2622,21 @@ static void submit_discard_share(struct work *work)
 static void *submit_work_thread(void *userdata)
 static void *submit_work_thread(void *userdata)
 {
 {
 	struct workio_cmd *wc = (struct workio_cmd *)userdata;
 	struct workio_cmd *wc = (struct workio_cmd *)userdata;
-	struct work *work = wc->work;
-	struct pool *pool = work->pool;
+	struct work *work;
+	struct pool *pool;
 	struct curl_ent *ce;
 	struct curl_ent *ce;
-	int failures = 0;
+	int failures;
 	time_t staleexpire;
 	time_t staleexpire;
 
 
 	pthread_detach(pthread_self());
 	pthread_detach(pthread_self());
 
 
 	applog(LOG_DEBUG, "Creating extra submit work thread");
 	applog(LOG_DEBUG, "Creating extra submit work thread");
 
 
+next_submit:
+	work = wc->work;
+	pool = work->pool;
+	failures = 0;
+
 	check_solve(work);
 	check_solve(work);
 
 
 	if (stale_work(work, true)) {
 	if (stale_work(work, true)) {
@@ -2677,6 +2692,18 @@ static void *submit_work_thread(void *userdata)
 	push_curl_entry(ce, pool);
 	push_curl_entry(ce, pool);
 out:
 out:
 	workio_cmd_free(wc);
 	workio_cmd_free(wc);
+
+	mutex_lock(&submitting_lock);
+	if (!list_empty(&submit_waiting)) {
+		applog(LOG_DEBUG, "submit_work continuing with queued submission");
+		wc = list_entry(submit_waiting.next, struct workio_cmd, list);
+		list_del(&wc->list);
+		mutex_unlock(&submitting_lock);
+		goto next_submit;
+	}
+	--submitting;
+	mutex_unlock(&submitting_lock);
+
 	return NULL;
 	return NULL;
 }
 }
 
 
@@ -3835,8 +3862,23 @@ static void *workio_thread(void *userdata)
 			ok = workio_get_work(wc);
 			ok = workio_get_work(wc);
 			break;
 			break;
 		case WC_SUBMIT_WORK:
 		case WC_SUBMIT_WORK:
+		{
+			mutex_lock(&submitting_lock);
+			if (submitting >= opt_submit_threads) {
+				if (list_empty(&submit_waiting))
+					applog(LOG_WARNING, "workio_thread queuing submissions (see --submit-threads)");
+				else
+					applog(LOG_DEBUG, "workio_thread queuing submission");
+				list_add_tail(&wc->list, &submit_waiting);
+				mutex_unlock(&submitting_lock);
+				break;
+			}
+			++submitting;
+			mutex_unlock(&submitting_lock);
+
 			ok = workio_submit_work(wc);
 			ok = workio_submit_work(wc);
 			break;
 			break;
+		}
 		default:
 		default:
 			ok = false;
 			ok = false;
 			break;
 			break;
@@ -5663,6 +5705,7 @@ int main(int argc, char *argv[])
 	strcpy(current_block, block->hash);
 	strcpy(current_block, block->hash);
 
 
 	INIT_LIST_HEAD(&scan_devices);
 	INIT_LIST_HEAD(&scan_devices);
+	INIT_LIST_HEAD(&submit_waiting);
 
 
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
 	memset(gpus, 0, sizeof(gpus));
 	memset(gpus, 0, sizeof(gpus));