From: Willy Tarreau Date: Thu, 31 Aug 2023 14:06:10 +0000 (+0200) Subject: MINOR: check/activity: collect some per-thread check activity stats X-Git-Tag: v2.9-dev5~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b7942a1c9d2dc4d91b8e8d7732cccef6642f99c;p=thirdparty%2Fhaproxy.git MINOR: check/activity: collect some per-thread check activity stats 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. --- diff --git a/include/haproxy/activity-t.h b/include/haproxy/activity-t.h index 309195f46d..9faeecdb31 100644 --- a/include/haproxy/activity-t.h +++ b/include/haproxy/activity-t.h @@ -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 diff --git a/src/activity.c b/src/activity.c index d2c8d8fb41..434c147133 100644 --- a/src/activity.c +++ b/src/activity.c @@ -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 */ diff --git a/src/check.c b/src/check.c index c69ab49bf0..5c1cd8a26a 100644 --- a/src/check.c +++ b/src/check.c @@ -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*/