From 8a03408d817c6c6e416d1e7334a7ada7d3b41b27 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 27 Feb 2019 10:45:55 +0100 Subject: [PATCH] MINOR: activity: add accept queue counters for pushed and overflows It's important to monitor the accept queues to know if some incoming connections had to be handled by their originating thread due to an overflow. It's also important to be able to confirm thread fairness. This patch adds "accq_pushed" to activity reporting, which reports the number of connections that were successfully pushed into each thread's queue, and "accq_full", which indicates the number of connections that couldn't be pushed because the thread's queue was full. --- include/types/activity.h | 2 ++ src/cli.c | 2 ++ src/listener.c | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/types/activity.h b/include/types/activity.h index f58d759ca..9cf4e731d 100644 --- a/include/types/activity.h +++ b/include/types/activity.h @@ -51,6 +51,8 @@ struct activity { struct freq_ctr cpust_1s; // avg amount of half-ms stolen over last second struct freq_ctr_period cpust_15s; // avg amount of half-ms stolen over last 15s unsigned int avg_loop_us; // average run time per loop over last 1024 runs + unsigned int accq_pushed; // accept queue connections pushed + unsigned int accq_full; // accept queue connection not pushed because full char __pad[0]; // unused except to check remaining room char __end[0] __attribute__((aligned(64))); // align size to 64. }; diff --git a/src/cli.c b/src/cli.c index 3c2a55d75..ae5e4e8e3 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1019,6 +1019,8 @@ static int cli_io_handler_show_activity(struct appctx *appctx) chunk_appendf(&trash, "\ncpust_ms_1s:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", read_freq_ctr(&activity[thr].cpust_1s)/2); chunk_appendf(&trash, "\ncpust_ms_15s:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", read_freq_ctr_period(&activity[thr].cpust_15s, 15000)/2); chunk_appendf(&trash, "\navg_loop_us:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", swrate_avg(activity[thr].avg_loop_us, TIME_STATS_SAMPLES)); + chunk_appendf(&trash, "\naccq_pushed:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].accq_pushed); + chunk_appendf(&trash, "\naccq_full:"); for (thr = 0; thr < global.nbthread; thr++) chunk_appendf(&trash, " %u", activity[thr].accq_full); chunk_appendf(&trash, "\n"); diff --git a/src/listener.c b/src/listener.c index 2b8c2dfab..0d7a1c480 100644 --- a/src/listener.c +++ b/src/listener.c @@ -852,13 +852,14 @@ void listener_accept(int fd) */ ring = &accept_queue_rings[t1]; if (accept_queue_push_mp(ring, cfd, l, &addr, laddr)) { + HA_ATOMIC_ADD(&activity[t1].accq_pushed, 1); task_wakeup(ring->task, TASK_WOKEN_IO); continue; } /* If the ring is full we do a synchronous accept on * the local thread here. - * FIXME: we should update some stats here. */ + HA_ATOMIC_ADD(&activity[t1].accq_full, 1); } #endif // USE_THREAD