]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: activity: add accept queue counters for pushed and overflows
authorWilly Tarreau <w@1wt.eu>
Wed, 27 Feb 2019 09:45:55 +0000 (10:45 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 27 Feb 2019 13:27:07 +0000 (14:27 +0100)
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
src/cli.c
src/listener.c

index f58d759ca29e91bb3b5cffa8470bbb66badd4afe..9cf4e731d044625ca4f7cad401eb4a466029b197 100644 (file)
@@ -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.
 };
index 3c2a55d75da89d0bd3d56ed81e804ecf94ad750e..ae5e4e8e3809e35f6363ae28f2a78e57c3897a2c 100644 (file)
--- 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");
 
index 2b8c2dfabcb22e96e3a33d4417cf8f6600c0cd96..0d7a1c4801affa1512e6bed31cf977fd27695c3e 100644 (file)
@@ -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