]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: ring: have only one thread at a time wake up all readers
authorWilly Tarreau <w@1wt.eu>
Sat, 2 Mar 2024 10:09:37 +0000 (11:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Mar 2024 17:34:19 +0000 (17:34 +0000)
commitc7bd7a68e4fb253aa2f26593b0cda0710c32872b
tree051aa34fd95fa667d9402c263f5524c66b489d52
parent1f8b14b7be51efcfe3c57fe9aecdc88c7acf3f5c
OPTIM: ring: have only one thread at a time wake up all readers

It's inefficient and counter-productive that each ring writer iterates
over all readers to wake them up. Let's just have one in charge of this,
it strongly limits contention. The only thing is that since the thread
is iterating over a list, we want to be sure that if the first readers
have already completed their job, they will be woken up again. For this
we keep a counter of messages delivered after the wakeup started, and
the waking thread will check it before going back to sleep. In order to
avoid looping forever, it will also drop its waking flag soon enough to
possibly let another one take it.

There used to be a few cases of watchdogs before this on a 24-core AMD
EPYC platform on the list iteration those never appeared anymore.
The perf has dropped a bit on 3C6T on the EPYC, from 6.61 to 6.0M but
remains unchanged at 24C48T.
include/haproxy/ring-t.h
src/ring.c