]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: polling: add an option to support busy polling
authorWilly Tarreau <w@1wt.eu>
Thu, 22 Nov 2018 17:07:59 +0000 (18:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Nov 2018 18:47:30 +0000 (19:47 +0100)
commitbeb859abcebf2dc1b025b7bb83e53a28192ea6e9
treec3e240baf584ca7d327694341beb8ba45b6993b0
parent48f8bc13685230b45dbcded7659bd8dbc6018791
MINOR: polling: add an option to support busy polling

In some situations, especially when dealing with low latency on processors
supporting a variable frequency or when running inside virtual machines,
each time the process waits for an I/O using the poller, the processor
goes back to sleep or is offered to another VM for a long time, and it
causes excessively high latencies.

A solution to this provided by this patch is to enable busy polling using
a global option. When busy polling is enabled, the pollers never sleep and
loop over themselves waiting for an I/O event to happen or for a timeout
to occur. On multi-processor machines it can significantly overheat the
processor but it usually results in much lower latencies.

A typical test consisting in injecting traffic over a single connection at
a time over the loopback shows a bump from 4640 to 8540 connections per
second on forwarded connections, indicating a latency reduction of 98
microseconds for each connection, and a bump from 12500 to 21250 for
locally terminated connections (redirects), indicating a reduction of
33 microseconds.

It is only usable with epoll and kqueue because select() and poll()'s
API is not convenient for such usages, and the level of performance they
are used in doesn't benefit from this anyway.

The option, which obviously remains disabled by default, can be turned
on using "busy-polling" in the global section, and turned off later
using "no busy-polling". Its status is reported in "show info" to help
troubleshooting suspicious CPU spikes.
doc/configuration.txt
include/types/global.h
include/types/stats.h
src/cfgparse-global.c
src/cfgparse.c
src/ev_epoll.c
src/ev_kqueue.c
src/stats.c