MEDIUM: muxes: mark idle conns tasklets with TASK_F_USR1
authorWilly Tarreau <w@1wt.eu>
Tue, 2 Mar 2021 15:51:09 +0000 (16:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 10 Mar 2021 14:11:16 +0000 (15:11 +0100)
commitb360bb887f1410ab0cff570f13a890003fbac61a
tree9eab3a26dd2dd3b5a28ecb6648fafb4a72a1179d
parent4676fa8dcd32d3384501960162b1140d5e0d2114
MEDIUM: muxes: mark idle conns tasklets with TASK_F_USR1

The muxes are touching the idle_conns_lock all the time now because
they need to be careful that no other thread has stolen their tasklet's
context.

This patch changes this a little bit by setting the TASK_F_USR1 flag on
the tasklet before marking a connection idle, and removing it once it's
not idle anymore. Thanks to this we have the guarantee that a tasklet
without this flag cannot be present in an idle list and does not need
to go through this costly lock. This is especially true for front
connections.

(cherry picked from commit e388f2fbca40197590bd15dce0f4eb4d6cded20a)
[wt: backported as really needed to address the high contention issues
 in multi-threaded environments: all I/O tasklets queue up on the
 takeover lock as soon as there's some activity on the reuse part,
 sometimes causing "reuse always" to be slower than "reuse never"!
 The context differs quite a bit due to the changes in tasks and idle
 conns in 2.4, but the main principle is to bypass the lock when
 TASK_F_USR1 is not set. ]
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/haproxy/task-t.h
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c