]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: buffers: do not round up buffer size during allocation
authorWilly Tarreau <w@1wt.eu>
Mon, 25 Jan 2016 01:23:25 +0000 (02:23 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Jan 2016 01:31:18 +0000 (02:31 +0100)
When users request 16384 bytes for a buffer, they get 16392 after
rounding up. This is problematic for SSL as it systematically
causes a small 8-bytes message to be appended after the first 16kB
message and costs about 15% of performance.

Let's add MEM_F_EXACT to use exactly the size we need. This requires
previous patch (MEDIUM: pools: add a new flag to avoid rounding pool
size up).

This issue was introduced in 1.6 and causes trouble there, so this
fix must be backported.

This is issue was reported by Gary Barrueto and diagnosed by Cyril Bonté.

src/buffer.c

index b083768e397170b22cde684c86c484cd450a4b55..f47fbddbdbd02c1a2a526730ecb65fd81d892ca7 100644 (file)
@@ -36,7 +36,7 @@ int init_buffer()
 {
        void *buffer;
 
-       pool2_buffer = create_pool("buffer", sizeof (struct buffer) + global.tune.bufsize, MEM_F_SHARED);
+       pool2_buffer = create_pool("buffer", sizeof (struct buffer) + global.tune.bufsize, MEM_F_SHARED|MEM_F_EXACT);
        if (!pool2_buffer)
                return 0;