]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pollers: only update the local date during busy polling
authorWilly Tarreau <w@1wt.eu>
Wed, 21 Sep 2022 06:11:38 +0000 (08:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 21 Sep 2022 07:06:28 +0000 (09:06 +0200)
This patch modifies epoll, kqueue and evports (the 3 pollers that support
busy polling) to only update the local date in the inner polling loop,
the global one being done when leaving the loop. Testing with epoll on
a 24c/48t machine showed a boost from 53M to 352M loops/s, indicating
that the loop was spending 85% of its time updating the global date or
causing side effects (which was confirmed with perf top showing 67% in
clock_update_global_date() alone).

src/ev_epoll.c
src/ev_evports.c
src/ev_kqueue.c

index 679e5e873447276e973822b3f153b64b8f477766..c42cf2ea5d35f4b8689089f4318bb9cef1d82bda 100644 (file)
@@ -230,7 +230,7 @@ static void _do_poll(struct poller *p, int exp, int wake)
                int timeout = (global.tune.options & GTUNE_BUSY_POLLING) ? 0 : wait_time;
 
                status = epoll_wait(epoll_fd[tid], epoll_events, global.tune.maxpollevents, timeout);
-               clock_update_date(timeout, status);
+               clock_update_local_date(timeout, status);
 
                if (status) {
                        activity[tid].poll_io++;
@@ -242,6 +242,7 @@ static void _do_poll(struct poller *p, int exp, int wake)
                        break;
        } while (1);
 
+       clock_update_global_date();
        fd_leaving_poll(wait_time, status);
 
        /* process polled events */
index 38fd1837903ecb1b6460498b3e7ead38214c7d18..07676e65a70e26d3fe59dacc5739d29373bda5a9 100644 (file)
@@ -211,7 +211,7 @@ static void _do_poll(struct poller *p, int exp, int wake)
                                break;
                        }
                }
-               clock_update_date(timeout, nevlist);
+               clock_update_local_date(timeout, nevlist);
 
                if (nevlist || interrupted)
                        break;
@@ -221,6 +221,7 @@ static void _do_poll(struct poller *p, int exp, int wake)
                        break;
        } while(1);
 
+       clock_update_global_date();
        fd_leaving_poll(wait_time, nevlist);
 
        if (nevlist > 0)
index e8097620253f140dd5c4cad13bfd5d60a2b582d3..f123e7be25320cb3ed04a4e571d59a443d42dc3c 100644 (file)
@@ -183,7 +183,7 @@ static void _do_poll(struct poller *p, int exp, int wake)
                                kev,       // struct kevent *eventlist
                                fd,        // int nevents
                                &timeout_ts); // const struct timespec *timeout
-               clock_update_date(timeout, status);
+               clock_update_local_date(timeout, status);
 
                if (status) {
                        activity[tid].poll_io++;
@@ -195,6 +195,7 @@ static void _do_poll(struct poller *p, int exp, int wake)
                        break;
        } while (1);
 
+       clock_update_global_date();
        fd_leaving_poll(wait_time, status);
 
        for (count = 0; count < status; count++) {