]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] sepoll: do not re-check whole list upon accepts
authorWilly Tarreau <w@1wt.eu>
Sun, 22 Mar 2009 18:25:46 +0000 (19:25 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 22 Mar 2009 18:25:46 +0000 (19:25 +0100)
There is already an optimisation in the speculative poller which
causes newly created FDs to be checked immediately after being
created. Unfortunately, this optimisation causes the whole spec
list to be re-checked while we're only interested in the new FDs.

Doing this minor change causes performance gains of up to 6% on
medium-sized objects with a few hundreds concurrent connections.

src/ev_sepoll.c

index 70c934db2a344ab5655b7337109b6c36dbf024ff..feca9670cb22af78f3f2c7db95d839fb51731e05 100644 (file)
@@ -243,7 +243,7 @@ REGPRM2 static int __fd_set(const int fd, int dir)
 
        if (i == FD_EV_IDLE) {
                // switch to SPEC state and allocate a SPEC entry.
-               fd_created = 1;
+               fd_created++;
                alloc_spec_entry(fd);
        switch_state:
                fd_list[fd].e ^= (unsigned int)(FD_EV_IN_SL << dir);
@@ -335,6 +335,10 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                fd = spec_list[spec_idx];
                eo = fd_list[fd].e;  /* save old events */
 
+               if (looping && --fd_created < 0) {
+                       /* we were just checking the newly created FDs */
+                       break;
+               }
                /*
                 * Process the speculative events.
                 *
@@ -535,7 +539,6 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                 * if we fail, the tasks are still woken up, and the FD gets marked
                 * for poll mode.
                 */
-               fd_created = 0;
                looping = 1;
                goto re_poll_once;
        }