]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM/MINOR: make it possible to change pipe size (tune.pipesize)
authorWilly Tarreau <w@1wt.eu>
Sun, 23 Oct 2011 19:14:29 +0000 (21:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 23 Oct 2011 19:15:38 +0000 (21:15 +0200)
By default, pipes are the default size for the system. But sometimes when
using TCP splicing, it can improve performance to increase pipe sizes,
especially if it is suspected that pipes are not filled and that many
calls to splice() are performed. This has an impact on the kernel's
memory footprint, so this must not be changed if impacts are not understood.

doc/configuration.txt
include/common/compat.h
include/types/global.h
src/cfgparse.c
src/pipe.c

index 653f0136723069c4d4dbf20d13555b61babe63c3..5cce3b46b892504adfd714522edeb52cbf267a58 100644 (file)
@@ -461,6 +461,7 @@ The following keywords are supported in the "global" section :
    - tune.maxaccept
    - tune.maxpollevents
    - tune.maxrewrite
+   - tune.pipesize
    - tune.rcvbuf.client
    - tune.rcvbuf.server
    - tune.sndbuf.client
@@ -753,6 +754,14 @@ tune.maxrewrite <number>
   larger than that. This means you don't have to worry about it when changing
   bufsize.
 
+tune.pipesize <number>
+  Sets the kernel pipe buffer size to this size (in bytes). By default, pipes
+  are the default size for the system. But sometimes when using TCP splicing,
+  it can improve performance to increase pipe sizes, especially if it is
+  suspected that pipes are not filled and that many calls to splice() are
+  performed. This has an impact on the kernel's memory footprint, so this must
+  not be changed if impacts are not understood.
+
 tune.rcvbuf.client <number>
 tune.rcvbuf.server <number>
   Forces the kernel socket receive buffer size on the client or the server side
index e134d5864fb8521724f4219b96ae2709e256898d..80e1dd2936dfd521abfd6fa044ebe15093e14154 100644 (file)
 #define MAXPATHLEN 128
 #endif
 
+/* On Linux, allows pipes to be resized */
+#ifndef F_SETPIPE_SZ
+#define F_SETPIPE_SZ (1024 + 7)
+#endif
+
 #if defined(TPROXY) && defined(NETFILTER)
 #include <linux/types.h>
 #include <linux/netfilter_ipv6.h>
index a5c7fa01c37f748614b633d6fc12124c7b860991..078a1d55cb17918eff6e349f92324239cf52e8f5 100644 (file)
@@ -96,6 +96,7 @@ struct global {
                int server_sndbuf; /* set server sndbuf to this value if not null */
                int server_rcvbuf; /* set server rcvbuf to this value if not null */
                int chksize;       /* check buffer size in bytes, defaults to BUFSIZE */
+               int pipesize;      /* pipe size in bytes, system defaults if zero */
        } tune;
        struct {
                char *prefix;           /* path prefix of unix bind socket */
index 39a289af36f24a71dd8e030eff3a5e77591770fa..ed64457625e925d75be3cf66cb052db61cdf436a 100644 (file)
@@ -587,6 +587,14 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                }
                global.tune.server_sndbuf = atol(args[1]);
        }
+       else if (!strcmp(args[0], "tune.pipesize")) {
+               if (*(args[1]) == 0) {
+                       Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+               global.tune.pipesize = atol(args[1]);
+       }
        else if (!strcmp(args[0], "uid")) {
                if (global.uid != 0) {
                        Alert("parsing [%s:%d] : user/uid already specified. Continuing.\n", file, linenum);
index ee6c92c9dd9ffa7be15c4f19cd2e895f4da55b19..76ab8f947db0154a6f406da20614374da09d6171 100644 (file)
@@ -58,6 +58,10 @@ struct pipe *get_pipe()
                pool_free2(pool2_pipe, ret);
                return NULL;
        }
+#ifdef F_SETPIPE_SZ
+       if (global.tune.pipesize)
+               fcntl(pipefd[0], F_SETPIPE_SZ, global.tune.pipesize);
+#endif
        ret->data = 0;
        ret->prod = pipefd[1];
        ret->cons = pipefd[0];