MINOR: tasks: Make the number of tasks to run at once configurable.
Instead of hardcoding 200, make the number of tasks to be run configurable
using tune.runqueue-depth. 200 is still the default.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 024502c..023973f 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -788,6 +788,22 @@
goto out;
global.mode |= MODE_QUIET;
}
+ else if (!strcmp(args[0], "tune.runqueue-depth")) {
+ if (alertif_too_many_args(1, file, linenum, args, &err_code))
+ goto out;
+ if (global.tune.runqueue_depth != 0) {
+ ha_alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]);
+ err_code |= ERR_ALERT;
+ goto out;
+ }
+ if (*(args[1]) == 0) {
+ ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
+ global.tune.runqueue_depth = atol(args[1]);
+
+ }
else if (!strcmp(args[0], "tune.maxpollevents")) {
if (alertif_too_many_args(1, file, linenum, args, &err_code))
goto out;
diff --git a/src/haproxy.c b/src/haproxy.c
index 6fd2e83..4e61e40 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1853,6 +1853,9 @@
if (global.tune.maxpollevents <= 0)
global.tune.maxpollevents = MAX_POLL_EVENTS;
+ if (global.tune.runqueue_depth <= 0)
+ global.tune.runqueue_depth = RUNQUEUE_DEPTH;
+
if (global.tune.recv_enough == 0)
global.tune.recv_enough = MIN_RECV_AT_ONCE_ENOUGH;
diff --git a/src/task.c b/src/task.c
index 3032010..3275188 100644
--- a/src/task.c
+++ b/src/task.c
@@ -243,7 +243,7 @@
tasks_run_queue_cur = tasks_run_queue; /* keep a copy for reporting */
nb_tasks_cur = nb_tasks;
- max_processed = 200;
+ max_processed = global.tune.runqueue_depth;
if (likely(global.nbthread > 1)) {
HA_SPIN_LOCK(TASK_RQ_LOCK, &rq_lock);
@@ -297,7 +297,7 @@
* get too much in the task list, but put a bit more than
* the max that will be run, to give a bit more fairness
*/
- while (max_processed + 20 > task_list_size[tid]) {
+ while (max_processed + (max_processed / 10) > task_list_size[tid]) {
/* Note: this loop is one of the fastest code path in
* the whole program. It should not be re-arranged
* without a good reason.