]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stream-int: make sure to always release empty buffers after sending
authorWilly Tarreau <w@1wt.eu>
Thu, 1 Aug 2019 12:17:02 +0000 (14:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 1 Aug 2019 12:34:01 +0000 (14:34 +0200)
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

index 75e60ff60981edeb012a3c976834e5327925e60d..d3080660935af43c9d7aa3751e027417b396bdc6 100644 (file)
@@ -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