From: Willy Tarreau Date: Sun, 22 Mar 2009 18:25:46 +0000 (+0100) Subject: [OPTIM] sepoll: do not re-check whole list upon accepts X-Git-Tag: v1.3.16~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=573fd806edf41c411945dac32eb541da0dca8f24;p=thirdparty%2Fhaproxy.git [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. --- diff --git a/src/ev_sepoll.c b/src/ev_sepoll.c index 70c934db2a..feca9670cb 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; }