Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Performance] Reduce Context Switching #2065

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
This change causes epoll_wait to only return events for a single FD o…
…n everycall.

With the use of EPOLLEXCLUSIVE we want to ensure that a single process is not being
woke to handle multiple FDs at once. This allows EPOLL to better distribute wake-ups to
processes that are actually ready to run. Without this a single process may be woken to handle
IO for multiple FDs, while other processes are available waiting for work.
rrb3942 committed Nov 17, 2022
commit 950a6b62639506308d610e8e0d7770e9f9925739
7 changes: 7 additions & 0 deletions io_wait_loop.h
Original file line number Diff line number Diff line change
@@ -175,7 +175,14 @@ inline static int io_wait_loop_epoll(io_wait_h* h, int t, int repeat)
unsigned int curr_time;

again:
#ifdef EPOLLEXCLUSIVE
/* When using EPOLLEXCLUSIVE we don't want a single wakeup to handle multiple fds at once
as it could introduce latency in handling requests.
Limit each wakeup to handling events from a single fd */
ret=n=epoll_wait(h->epfd, h->ep_array, 1, t*1000);
#else
ret=n=epoll_wait(h->epfd, h->ep_array, h->fd_no, t*1000);
#endif
if (n==-1){
if (errno == EINTR) {
goto again; /* signal, ignore it */