]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: mux-h2: don't allocate more buffers per connections than streams
authorWilly Tarreau <w@1wt.eu>
Thu, 9 Nov 2023 15:53:32 +0000 (16:53 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 9 Nov 2023 16:24:00 +0000 (17:24 +0100)
commit0a7ab7067f6ed88cba4beb1fefc4a3612acfa572
tree72070e22bcead3d13a4a6b2cd660cf0fb63a2f8d
parenta13f8425f068880117085c02bd004dc0e68dc55a
OPTIM: mux-h2: don't allocate more buffers per connections than streams

When an H2 mux works with a slow downstream connection and without the
mux-mux mode, it is possible that a single stream will allocate all 32
buffers in the connection. This is not desirable at all because 1) it
brings no value, and 2) it allocates a lot of memory per connection,
which, in addition to using a lot of memory, tends to degrade performance
due to cache thrashing.

This patch improves the situation by refraining from sending data frames
over a connection when more mbufs than streams are allocated. On a test
featuring 10k connections each with a single stream reading from the
cache, this patch reduces the RAM usage from ~180k buffers to ~20k bufs,
and improves the bandwidth. This may even be backported later to recent
versions to improve memory usage. Note however that it is efficient only
when combined with e16762f8a ("OPTIM: mux-h2: call h2_send() directly
from h2_snd_buf()"), and tends to slightly reduce the single-stream
performance without it, so in case of a backport, the two need to be
considered together.
src/mux_h2.c