BUG/MINOR: select: fix excess number of dead/skip reported
authorWilly Tarreau <w@1wt.eu>
Fri, 30 Jul 2021 11:55:36 +0000 (13:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 12 Aug 2021 15:00:43 +0000 (17:00 +0200)
In 1.8, commit ab62f5195 ("MINOR: polling: Use fd_update_events to update
events seen for a fd") updated the pollers to rely on fd_update_events(),
but the modification delayed the test of presence of the FD in the report,
resulting in owner/thread_mask and possibly event updates being performed
for each FD appearing in a block of 32 FDs around an active one. This
caused the request rate to be ~3 times lower with select() than poll()
under 6 threads.

This can be backported as far as 1.8.

(cherry picked from commit fcc5281513eabe0d7790d98e50ee8cd9be216c1b)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit cf3092fc2d863491f4ae8b115f679a234ead965f)
Signed-off-by: Willy Tarreau <w@1wt.eu>

src/ev_select.c

index aca1ea8..a362b28 100644 (file)
@@ -197,6 +197,15 @@ static void _do_poll(struct poller *p, int exp, int wake)
                for (count = BITS_PER_INT, fd = fds * BITS_PER_INT; count && fd < maxfd; count--, fd++) {
                        unsigned int n = 0;
 
+                       if (FD_ISSET(fd, tmp_evts[DIR_RD]))
+                               n |= FD_EV_READY_R;
+
+                       if (FD_ISSET(fd, tmp_evts[DIR_WR]))
+                               n |= FD_EV_READY_W;
+
+                       if (!n)
+                               continue;
+
 #ifdef DEBUG_FD
                        _HA_ATOMIC_ADD(&fdtab[fd].event_count, 1);
 #endif
@@ -210,12 +219,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
                                continue;
                        }
 
-                       if (FD_ISSET(fd, tmp_evts[DIR_RD]))
-                               n |= FD_EV_READY_R;
-
-                       if (FD_ISSET(fd, tmp_evts[DIR_WR]))
-                               n |= FD_EV_READY_W;
-
                        fd_update_events(fd, n);
                }
        }