]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tasks: Make the number of tasks to run at once configurable.
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 24 May 2018 16:59:04 +0000 (18:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 26 May 2018 18:03:24 +0000 (20:03 +0200)
Instead of hardcoding 200, make the number of tasks to be run configurable
using tune.runqueue-depth. 200 is still the default.

doc/configuration.txt
include/common/defaults.h
include/types/global.h
src/cfgparse.c
src/haproxy.c
src/task.c

index 67b4b3ab87d131a21569e9df6a7262287aa1e148..e27d66627fedd37e8f29bcfa50a5e0d73a45179f 100644 (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
index f53c611e270c57e58803779c7a1e1ddbc99b51fb..f5c74dbfe5ce9086788dfab98a301ecc55dd720e 100644 (file)
 #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.
index bd7761cd6ff50506788d48f85b2169c649c3e593..d603c4261180b35c332040874c78a2d63082e857 100644 (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 */
index 024502c4b8639515fc7b85e14480204c428d722e..023973f40e0ac37d1452fa5587093b78739c49fa 100644 (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;
index 6fd2e83832ce9a770bf9a290c572b79572e117df..4e61e4056fd6a7149eef7233e55c2d6f623930a8 100644 (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;
 
index 3032010ba04c3e4693e78f089b7d9a62e2774425..327518896997ddc2c69c90ee9c7a7b745543faed 100644 (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.