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.
This commit is contained in:
Olivier Houchard 2018-05-24 18:59:04 +02:00 committed by Willy Tarreau
parent b0bdae7b88
commit 1599b80360
6 changed files with 33 additions and 2 deletions

View File

@ -648,6 +648,7 @@ The following keywords are supported in the "global" section :
- tune.rcvbuf.client
- tune.rcvbuf.server
- tune.recv_enough
- tune.runqueue-depth
- tune.sndbuf.client
- tune.sndbuf.server
- tune.ssl.cachesize
@ -1627,6 +1628,11 @@ tune.recv_enough <number>
may be changed by this setting to better deal with workloads involving lots
of short messages such as telnet or SSH sessions.
tune.runqueue-depth <number>
Sets the maxinum amount of task that can be processed at once when running
tasks. The default value is 200. Increasing it may incur latency when
dealing with I/Os, making it too small can incur extra overhead.
tune.sndbuf.client <number>
tune.sndbuf.server <number>
Forces the kernel socket send buffer size on the client or the server side to

View File

@ -135,6 +135,11 @@
#define MAX_POLL_EVENTS 200
#endif
// the max number of tasks to run at once
#ifndef RUNQUEUE_DEPTH
#define RUNQUEUE_DEPTH 200
#endif
// cookie delimitor in "prefix" mode. This character is inserted between the
// persistence cookie and the original value. The '~' is allowed by RFC6265,
// and should not be too common in server names.

View File

@ -136,6 +136,7 @@ struct global {
int maxpollevents; /* max number of poll events at once */
int maxaccept; /* max number of consecutive accept() */
int options; /* various tuning options */
int runqueue_depth;/* max number of tasks to run at once */
int recv_enough; /* how many input bytes at once are "enough" */
int bufsize; /* buffer size in bytes, defaults to BUFSIZE */
int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */

View File

@ -788,6 +788,22 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
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;

View File

@ -1853,6 +1853,9 @@ static void init(int argc, char **argv)
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;

View File

@ -243,7 +243,7 @@ void process_runnable_tasks()
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 @@ void process_runnable_tasks()
* 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.