From d279b14a9998c55b58ec0dacd7847900235b7a7a Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 25 Nov 2025 08:54:36 -0400 Subject: [PATCH] MT#55283 export poller thread stats Change-Id: I5b8b2e6c791d27a1d29e982c72005aff38e7cd6d --- daemon/main.c | 2 +- daemon/statistics.c | 13 +++++++++++++ include/main.h | 2 ++ t/test-stats.c | 23 +++++++++++++++++++++++ t/test-transcode.c | 2 ++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/daemon/main.c b/daemon/main.c index 6e80875b0..b746c5260 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -68,7 +68,7 @@ struct poller **rtpe_pollers; struct poller *rtpe_control_poller; static unsigned int num_rtpe_pollers; -static unsigned int num_poller_threads; +unsigned int num_poller_threads; struct poller_thread *rtpe_poller_threads; unsigned int num_media_pollers; unsigned int rtpe_poller_rr_iter; diff --git a/daemon/statistics.c b/daemon/statistics.c index e542516af..d274014ca 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -912,6 +912,19 @@ stats_metric_q *statistics_gather_metrics(struct interface_sampled_rate_stats *i mutex_unlock(&rtpe_codec_stats_lock); HEADER("]", ""); + HEADER("poller_threads", NULL); + HEADER("[", NULL); + for (unsigned int i = 0; i < num_poller_threads; i++) { + struct poller_thread *pt = &rtpe_poller_threads[i]; + HEADER("{", ""); + METRICs("index", "%u", i); + METRICs("pid", "%u", (unsigned int) pt->pid); + METRICs("wakeups", "%" PRIu64, atomic64_get_na(&pt->wakeups)); + METRICs("items", "%" PRIu64, atomic64_get_na(&pt->items)); + HEADER("}", ""); + } + HEADER("]", NULL); + HEADER("}", NULL); return ret; diff --git a/include/main.h b/include/main.h index c93149d28..adaf26782 100644 --- a/include/main.h +++ b/include/main.h @@ -316,6 +316,8 @@ extern struct poller **rtpe_pollers; // at least one poller, in an array extern struct poller *rtpe_control_poller; // poller for control sockets (maybe rtpe_pollers[0]) extern unsigned int num_media_pollers; // for media sockets, >= 1 extern unsigned int rtpe_poller_rr_iter; // round-robin assignment of pollers to each thread +extern unsigned int num_poller_threads; +extern struct poller_thread *rtpe_poller_threads; INLINE struct poller *rtpe_get_poller(void) { diff --git a/t/test-stats.c b/t/test-stats.c index 1b2cbbe08..f3538e44c 100644 --- a/t/test-stats.c +++ b/t/test-stats.c @@ -18,6 +18,8 @@ struct rtpengine_config rtpe_config = { }; struct rtpengine_config initial_rtpe_config; struct poller **rtpe_pollers = (struct poller *[]) {NULL}; +unsigned int num_poller_threads; +struct poller_thread *rtpe_poller_threads; struct poller *rtpe_control_poller; struct poller *uring_poller; unsigned int num_media_pollers = 1; @@ -1265,6 +1267,9 @@ int main(void) { "[\n" "\n" "]\n" + "poller_threads\n" + "[\n" + "]\n" "}\n"); RTPE_STATS_INC(ng_commands[OP_OFFER]); @@ -2451,6 +2456,9 @@ int main(void) { "[\n" "\n" "]\n" + "poller_threads\n" + "[\n" + "]\n" "}\n"); RTPE_STATS_INC(ng_commands[OP_ANSWER]); @@ -3634,6 +3642,9 @@ int main(void) { "[\n" "\n" "]\n" + "poller_threads\n" + "[\n" + "]\n" "}\n"); // test cmd_ps_min/max/avg @@ -4836,6 +4847,9 @@ int main(void) { "[\n" "\n" "]\n" + "poller_threads\n" + "[\n" + "]\n" "}\n"); // test average call duration @@ -6027,6 +6041,9 @@ int main(void) { "[\n" "\n" "]\n" + "poller_threads\n" + "[\n" + "]\n" "}\n"); @@ -7212,6 +7229,9 @@ int main(void) { "[\n" "\n" "]\n" + "poller_threads\n" + "[\n" + "]\n" "}\n"); @@ -8400,6 +8420,9 @@ int main(void) { "[\n" "\n" "]\n" + "poller_threads\n" + "[\n" + "]\n" "}\n"); diff --git a/t/test-transcode.c b/t/test-transcode.c index a28353ac8..156b5b3a8 100644 --- a/t/test-transcode.c +++ b/t/test-transcode.c @@ -13,6 +13,8 @@ int _log_facility_dtmf; struct rtpengine_config rtpe_config; struct rtpengine_config initial_rtpe_config; struct poller **rtpe_pollers; +unsigned int num_poller_threads; +struct poller_thread *rtpe_poller_threads; struct poller *rtpe_control_poller; struct poller *uring_poller; unsigned int num_media_pollers;