]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: listener: implement multi-queue accept for threads
authorWilly Tarreau <w@1wt.eu>
Sun, 27 Jan 2019 14:37:19 +0000 (15:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 27 Feb 2019 13:27:07 +0000 (14:27 +0100)
commit1efafce61f20b21841990af008b3b838244782e2
tree9460595c5b135b58fb1f60ded907261b2bb980f5
parentb2b50a7784ae6b3feffa49a5010d5b82ead32ab9
MINOR: listener: implement multi-queue accept for threads

There is one point where we can migrate a connection to another thread
without taking risk, it's when we accept it : the new FD is not yet in
the fd cache and no task was created yet. It's still possible to assign
it a different thread than the one which accepted the connection. The
only requirement for this is to have one accept queue per thread and
their respective processing tasks that have to be woken up each time
an entry is added to the queue.

This is a multiple-producer, single-consumer model. Entries are added
at the queue's tail and the processing task is woken up. The consumer
picks entries at the head and processes them in order. The accept queue
contains the fd, the source address, and the listener. Each entry of
the accept queue was rounded up to 64 bytes (one cache line) to avoid
cache aliasing because tests have shown that otherwise performance
suffers a lot (5%). A test has shown that it's important to have at
least 256 entries for the rings, as at 128 it's still possible to fill
them often at high loads on small thread counts.

The processing task does almost nothing except calling the listener's
accept() function and updating the global session and SSL rate counters
just like listener_accept() does on synchronous calls.

At this point the accept queue is implemented but not used.
include/proto/listener.h
include/types/listener.h
src/listener.c