]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MAJOR: tasks: create per-thread wait queues
authorWilly Tarreau <w@1wt.eu>
Mon, 15 Oct 2018 12:52:21 +0000 (14:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 15 Oct 2018 17:04:40 +0000 (19:04 +0200)
commitb20aa9eef354b5cca3f9ea43aab38d568e7fdeb7
tree7fb242288772431cb88c2f4aab8d7475f18802c2
parent87d54a9a6dee5170c7c12e1bd3f43bd9f49634e7
MAJOR: tasks: create per-thread wait queues

Now we still have a main contention point with the timers in the main
wait queue, but the vast majority of the tasks are pinned to a single
thread. This patch creates a per-thread wait queue and queues a task
to the local wait queue without any locking if the task is bound to a
single thread (the current one) otherwise to the shared queue using
locking. This significantly reduces contention on the wait queue. A
test with 12 threads showed 11 ms spent in the WQ lock compared to
4.7 seconds in the same test without this change. The cache miss ratio
decreased from 19.7% to 19.2% on the 12-thread test, and its performance
increased by 1.5%.

Another indirect benefit is that the average queue size is divided
by the number of threads, which roughly removes log(nbthreads) levels
in the tree and further speeds up lookups.
include/proto/task.h
src/task.c