Skip to content

Commit 950a6b6

Browse files
committed
This change causes epoll_wait to only return events for a single FD on 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.
1 parent b8194f1 commit 950a6b6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

io_wait_loop.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,14 @@ inline static int io_wait_loop_epoll(io_wait_h* h, int t, int repeat)
175175
unsigned int curr_time;
176176

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

0 commit comments

Comments
 (0)