MXS-1646 Remove non-blocking/timed epoll_wait calls

Since a shutdown message will now be sent via the regular epoll route,
there is no need to regularily wake up from epoll in order to check
whether shutdown has been initiated, but we can simply wait in epoll_wait
until told to wake up.
This commit is contained in:
Johan Wikman 2018-02-05 10:35:14 +02:00
parent 771716e9db
commit 099b976773
3 changed files with 17 additions and 50 deletions

View File

@ -1406,10 +1406,16 @@ handle_global_item(const char *name, const char *value)
}
else if (strcmp(name, CN_NON_BLOCKING_POLLS) == 0)
{
// DEPRECATED in 2.3, remove in 2.4
MXS_WARNING("The configuration option '%s' has no meaning and has been deprecated.",
CN_NON_BLOCKING_POLLS);
gateway.n_nbpoll = atoi(value);
}
else if (strcmp(name, CN_POLL_SLEEP) == 0)
{
// DEPRECATED in 2.3, remove in 2.4
MXS_WARNING("The configuration option '%s' has no meaning and has been deprecated.",
CN_POLL_SLEEP);
gateway.pollsleep = atoi(value);
}
else if (strcmp(name, CN_MS_TIMESTAMP) == 0)

View File

@ -60,7 +60,9 @@ struct this_unit
bool initialized; // Whether the initialization has been performed.
int n_workers; // How many workers there are.
Worker** ppWorkers; // Array of worker instances.
// DEPRECATED in 2.3, remove in 2.4.
int number_poll_spins; // Maximum non-block polls
// DEPRECATED in 2.3, remove in 2.4.
int max_poll_sleep; // Maximum block time
int epoll_listener_fd; // Shared epoll descriptor for listening descriptors.
} this_unit =
@ -1107,8 +1109,6 @@ void Worker::thread_main(void* pArg)
void Worker::poll_waitevents()
{
struct epoll_event events[MAX_EVENTS];
int i, nfds, timeout_bias = 1;
int poll_spins = 0;
m_state = IDLE;
@ -1117,40 +1117,17 @@ void Worker::poll_waitevents()
m_state = POLLING;
atomic_add_int64(&m_statistics.n_polls, 1);
if ((nfds = epoll_wait(m_epoll_fd, events, MAX_EVENTS, 0)) == -1)
int nfds;
if ((nfds = epoll_wait(m_epoll_fd, events, MAX_EVENTS, -1)) == -1)
{
int eno = errno;
errno = 0;
MXS_DEBUG("%lu [poll_waitevents] epoll_wait returned "
MXS_ERROR("%lu [poll_waitevents] epoll_wait returned "
"%d, errno %d",
pthread_self(),
nfds,
eno);
}
/*
* If there are no new descriptors from the non-blocking call
* and nothing to process on the event queue then for do a
* blocking call to epoll_wait.
*
* We calculate a timeout bias to alter the length of the blocking
* call based on the time since we last received an event to process
*/
else if (nfds == 0 && poll_spins++ > this_unit.number_poll_spins)
{
if (timeout_bias < 10)
{
timeout_bias++;
}
atomic_add_int64(&m_statistics.blockingpolls, 1);
nfds = epoll_wait(m_epoll_fd,
events,
MAX_EVENTS,
(this_unit.max_poll_sleep * timeout_bias) / 10);
if (nfds == 0)
{
poll_spins = 0;
}
}
if (nfds > 0)
{
@ -1160,12 +1137,6 @@ void Worker::poll_waitevents()
m_statistics.evq_max = nfds;
}
timeout_bias = 1;
if (poll_spins <= this_unit.number_poll_spins + 1)
{
atomic_add_int64(&m_statistics.n_nbpollev, 1);
}
poll_spins = 0;
MXS_DEBUG("%lu [poll_waitevents] epoll_wait found %d fds",
pthread_self(),
nfds);

View File

@ -598,27 +598,13 @@ struct subcommand setoptions[] =
{
"pollsleep", 1, 1, set_pollsleep,
"Set poll sleep period",
"Usage: set pollsleep VALUE\n"
"\n"
"Parameters:\n"
"VALUE Poll sleep in milliseconds\n"
"\n"
"Sets the maximum poll sleep period in milliseconds\n"
"\n"
"Example: set pollsleep 100",
"Deprecated in 2.3",
{ARG_TYPE_NUMERIC}
},
{
"nbpolls", 1, 1, set_nbpoll,
"Set non-blocking polls",
"Usage: set nbpolls VALUE\n"
"\n"
"Parameters:\n"
"VALUE Number of non-blocking polls\n"
"\n"
"Sets the number of non-blocking polls\n"
"\n"
"Example: set nbpolls 5",
"Deprecated in 2.3",
{ARG_TYPE_NUMERIC}
},
{
@ -2563,6 +2549,8 @@ static void disable_log_priority(DCB *dcb, char *arg1)
static void
set_pollsleep(DCB *dcb, int sleeptime)
{
// DEPRECATED in 2.3, remove in 2.4.
dcb_printf(dcb, "The configuration parameter 'pollsleep' has been deprecated in 2.3.");
poll_set_maxwait(sleeptime);
}
@ -2575,6 +2563,8 @@ set_pollsleep(DCB *dcb, int sleeptime)
static void
set_nbpoll(DCB *dcb, int nb)
{
// DEPRECATED in 2.3, remove in 2.4.
dcb_printf(dcb, "The configuration parameter 'nbpoll' has been deprecated in 2.3.");
poll_set_nonblocking_polls(nb);
}