MINOR: pollers: only update the local date during busy polling
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).
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index 679e5e8..c42cf2e 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -230,7 +230,7 @@
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 @@
break;
} while (1);
+ clock_update_global_date();
fd_leaving_poll(wait_time, status);
/* process polled events */
diff --git a/src/ev_evports.c b/src/ev_evports.c
index 38fd183..07676e6 100644
--- a/src/ev_evports.c
+++ b/src/ev_evports.c
@@ -211,7 +211,7 @@
break;
}
}
- clock_update_date(timeout, nevlist);
+ clock_update_local_date(timeout, nevlist);
if (nevlist || interrupted)
break;
@@ -221,6 +221,7 @@
break;
} while(1);
+ clock_update_global_date();
fd_leaving_poll(wait_time, nevlist);
if (nevlist > 0)
diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c
index e809762..f123e7b 100644
--- a/src/ev_kqueue.c
+++ b/src/ev_kqueue.c
@@ -183,7 +183,7 @@
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 @@
break;
} while (1);
+ clock_update_global_date();
fd_leaving_poll(wait_time, status);
for (count = 0; count < status; count++) {