]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: check/activity: collect some per-thread check activity stats
authorWilly Tarreau <w@1wt.eu>
Thu, 31 Aug 2023 14:06:10 +0000 (16:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 Sep 2023 06:26:06 +0000 (08:26 +0200)
We now count the number of times a check was started on each thread
and the number of times a check was adopted. This helps understand
better what is observed regarding checks.

include/haproxy/activity-t.h
src/activity.c
src/check.c

index 309195f46da9b93f50ba5ce9aba2f0bcf129091f..9faeecdb3103f6347ea3f8f4f599c0f91a755a8d 100644 (file)
@@ -95,6 +95,7 @@ struct activity {
        unsigned int long_rq;      // process_runnable_tasks() left with tasks in the run queue
        unsigned int cpust_total;  // sum of half-ms stolen per thread
        unsigned int fd_takeover;  // number of times this thread stole another one's FD
+       unsigned int check_adopted;// number of times a check was migrated to this thread
        ALWAYS_ALIGN(64);
 
        struct freq_ctr cpust_1s;  // avg amount of half-ms stolen over last second
@@ -105,6 +106,7 @@ struct activity {
        unsigned int accq_full;    // accept queue connection not pushed because full
        unsigned int pool_fail;    // failed a pool allocation
        unsigned int buf_wait;     // waited on a buffer allocation
+       unsigned int check_started;// number of times a check was started on this thread
 #if defined(DEBUG_DEV)
        /* keep these ones at the end */
        unsigned int ctr0;         // general purposee debug counter
index d2c8d8fb410777b99b59916b62a267af2691f1f3..434c14713362e40602eb23aa3e27519c95c55a12 100644 (file)
@@ -1142,7 +1142,9 @@ static int cli_io_handler_show_activity(struct appctx *appctx)
 #ifdef USE_THREAD
                case __LINE__: SHOW_VAL("accq_ring:",    accept_queue_ring_len(&accept_queue_rings[thr]), _tot); break;
                case __LINE__: SHOW_VAL("fd_takeover:",  activity[thr].fd_takeover, _tot); break;
+               case __LINE__: SHOW_VAL("check_adopted:",activity[thr].check_adopted, _tot); break;
 #endif
+               case __LINE__: SHOW_VAL("check_started:",activity[thr].check_started, _tot); break;
 
 #if defined(DEBUG_DEV)
                        /* keep these ones at the end */
index c69ab49bf04f8b252e4bfd6a14ccb8bf603b6f0f..5c1cd8a26a40ac1785bd8e91831c259964d6adec 100644 (file)
@@ -1137,7 +1137,11 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
                 */
                uint my_load = HA_ATOMIC_LOAD(&th_ctx->rq_total);
 
-               if (!(check->state & CHK_ST_READY) && my_load >= 2) {
+               if (check->state & CHK_ST_READY) {
+                       /* check was migrated */
+                       activity[tid].check_adopted++;
+               }
+               else if (my_load >= 2) {
                        uint new_tid  = statistical_prng_range(global.nbthread);
                        uint new_load = HA_ATOMIC_LOAD(&ha_thread_ctx[new_tid].rq_total);
 
@@ -1164,6 +1168,7 @@ struct task *process_chk_conn(struct task *t, void *context, unsigned int state)
 
                /* OK let's run, now we cannot roll back anymore */
                check->state |= CHK_ST_READY;
+               activity[tid].check_started++;
        }
 
        /* at this point, CHK_ST_SLEEPING = 0 and CHK_ST_READY = 1*/