eventpoll: add support for min-wait
authorJens Axboe <axboe@kernel.dk>
Fri, 19 Aug 2022 03:00:18 +0000 (21:00 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 12 Apr 2023 14:55:59 +0000 (08:55 -0600)
commita4130d26541d92c8dcc68071bf1ded9386bc5cea
treec4a8d1fdd61b007cf86242c1f68dd58c7d1417c8
parentf9072ca18bad0b1e5212f99ab34b068597960c10
eventpoll: add support for min-wait

This adds the necessary infrastructure to support a minimum wait for
reaping events, API for setting or applying a minimum wait will come
in the following patches.

For medium workload efficiencies, some production workloads inject
artificial timers or sleeps before calling epoll_wait() to get
better batching and higher efficiencies. While this does help, it's
not as efficient as it could be. By adding support for epoll_wait()
for this directly, we can avoids extra context switches and scheduler
and timer overhead.

As an example, running an AB test on an identical workload at about
~370K reqs/second, without this change and with the sleep hack
mentioned above (using 200 usec as the timeout), we're doing 310K-340K
non-voluntary context switches per second. Idle CPU on the host is 27-34%.
With the the sleep hack removed and epoll set to the same 200 usec
value, we're handling the exact same load but at 292K-315k non-voluntary
context switches and idle CPU of 33-41%, a substantial win.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/eventpoll.c