From 573fd806edf41c411945dac32eb541da0dca8f24 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 22 Mar 2009 19:25:46 +0100 Subject: [PATCH] [OPTIM] sepoll: do not re-check whole list upon accepts 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ev_sepoll.c b/src/ev_sepoll.c index 70c934db2..feca9670c 100644 --- a/src/ev_sepoll.c +++ b/src/ev_sepoll.c @@ -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; }