From a64c703374455032359cc566d676525f989da14a Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 1 Aug 2019 14:17:02 +0200 Subject: [PATCH] BUG/MINOR: stream-int: make sure to always release empty buffers after sending There are some situations, after sending a request or response, upon I/O completion, or applet execution, where we end up with an empty buffer that was not released. This results in excessive memory usage (back to 1.5) and a lower CPU cache efficiency since buffers are not recycled as fast. This has changed since the places where we send have changed with the new layering, but not all cases susceptible of leaving an empty buffer were properly spotted. Doing so reduces the memory pressure on buffers by about 2/3 in high traffic tests. This should be backported to 2.0 and maybe 1.9. --- src/stream_interface.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/stream_interface.c b/src/stream_interface.c index 75e60ff60..d30806609 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -618,8 +618,7 @@ static int si_cs_process(struct conn_stream *cs) * stream-int status. */ stream_int_notify(si); - channel_release_buffer(ic, &(si_strm(si)->buffer_wait)); - + stream_release_buffers(si_strm(si)); return 0; } @@ -788,6 +787,7 @@ struct task *si_cs_io_cb(struct task *t, void *ctx, unsigned short state) if (ret != 0) si_cs_process(cs); + stream_release_buffers(si_strm(si)); return (NULL); } @@ -1572,6 +1572,7 @@ void si_applet_wake_cb(struct stream_interface *si) /* update the stream-int, channels, and possibly wake the stream up */ stream_int_notify(si); + stream_release_buffers(si_strm(si)); /* stream_int_notify may have passed through chk_snd and released some * RXBLK flags. Process_stream will consider those flags to wake up the -- 2.47.3