diff --git a/server/core/poll.cc b/server/core/poll.cc index 19eacd6a9..1f960d6f0 100644 --- a/server/core/poll.cc +++ b/server/core/poll.cc @@ -92,31 +92,9 @@ static SPINLOCK poll_msg_lock = SPINLOCK_INIT; static void poll_check_message(void); static bool poll_dcb_session_check(DCB *dcb, const char *function); -/** - * Thread load average, this is the average number of descriptors in each - * poll completion, a value of 1 or less is the ideal. - */ -static double load_average = 0.0; -static int load_samples = 0; -static int load_nfds = 0; -static double current_avg = 0.0; -static double *avg_samples = NULL; -static int next_sample = 0; -static int n_avg_samples; - /* Thread statistics data */ static int n_threads; /*< No. of threads */ -/** - * How frequently to call the poll_loadav function used to monitor the load - * average of the poll subsystem. - */ -#define POLL_LOAD_FREQ 10 -/** - * Periodic function to collect load data for average calculations - */ -static void poll_loadav(void *); - /** * Initialise the polling system we are using for the gateway. * @@ -132,15 +110,6 @@ poll_init() exit(-1); } - hktask_add("Load Average", poll_loadav, NULL, POLL_LOAD_FREQ); - n_avg_samples = 15 * 60 / POLL_LOAD_FREQ; - avg_samples = (double *)MXS_MALLOC(sizeof(double) * n_avg_samples); - MXS_ABORT_IF_NULL(avg_samples); - for (int i = 0; i < n_avg_samples; i++) - { - avg_samples[i] = 0.0; - } - number_poll_spins = config_nbpolls(); max_poll_sleep = config_pollsleep(); } @@ -348,10 +317,6 @@ void poll_waitevents(int epoll_fd, poll_stats->thread_state = THREAD_PROCESSING; poll_stats->n_fds[(nfds < MAXNFDS ? (nfds - 1) : MAXNFDS - 1)]++; - - load_average = (load_average * load_samples + nfds) / (load_samples + 1); - atomic_add(&load_samples, 1); - atomic_add(&load_nfds, nfds); } uint64_t cycle_start = hkheartbeat; @@ -803,55 +768,14 @@ dprintPollStats(DCB *dcb) void dShowThreads(DCB *dcb) { - int i, j, n; - const char *state; - double avg1 = 0.0, avg5 = 0.0, avg15 = 0.0; - dcb_printf(dcb, "Polling Threads.\n\n"); - dcb_printf(dcb, "Historic Thread Load Average: %.2f.\n", load_average); - dcb_printf(dcb, "Current Thread Load Average: %.2f.\n", current_avg); - - /* Average all the samples to get the 15 minute average */ - for (i = 0; i < n_avg_samples; i++) - { - avg15 += avg_samples[i]; - } - avg15 = avg15 / n_avg_samples; - - /* Average the last third of the samples to get the 5 minute average */ - n = 5 * 60 / POLL_LOAD_FREQ; - i = next_sample - (n + 1); - if (i < 0) - { - i += n_avg_samples; - } - for (j = i; j < i + n; j++) - { - avg5 += avg_samples[j % n_avg_samples]; - } - avg5 = (3 * avg5) / (n_avg_samples); - - /* Average the last 15th of the samples to get the 1 minute average */ - n = 60 / POLL_LOAD_FREQ; - i = next_sample - (n + 1); - if (i < 0) - { - i += n_avg_samples; - } - for (j = i; j < i + n; j++) - { - avg1 += avg_samples[j % n_avg_samples]; - } - avg1 = (15 * avg1) / (n_avg_samples); - - dcb_printf(dcb, "15 Minute Average: %.2f, 5 Minute Average: %.2f, " - "1 Minute Average: %.2f\n\n", avg15, avg5, avg1); - dcb_printf(dcb, "Pending event queue length averages:\n"); dcb_printf(dcb, " ID | State \n"); dcb_printf(dcb, "----+------------\n"); - for (i = 0; i < n_threads; i++) + for (int i = 0; i < n_threads; i++) { + const char *state = "Unknown"; + switch (pollStats[i].thread_state) { case THREAD_STOPPED: @@ -869,46 +793,15 @@ dShowThreads(DCB *dcb) case THREAD_ZPROCESSING: state = "Collecting"; break; + + default: + ss_dassert(!true); } dcb_printf(dcb, " %2d | %s\n", i, state); } } -/** - * The function used to calculate time based load data. This is called by the - * housekeeper every POLL_LOAD_FREQ seconds. - * - * @param data Argument required by the housekeeper but not used here - */ -static void -poll_loadav(void *data) -{ - static int last_samples = 0, last_nfds = 0; - int new_samples, new_nfds; - - new_samples = load_samples - last_samples; - new_nfds = load_nfds - last_nfds; - last_samples = load_samples; - last_nfds = load_nfds; - - /* POLL_LOAD_FREQ average is... */ - if (new_samples) - { - current_avg = new_nfds / new_samples; - } - else - { - current_avg = 0.0; - } - avg_samples[next_sample] = current_avg; - next_sample++; - if (next_sample >= n_avg_samples) - { - next_sample = 0; - } -} - namespace {