From: Willy Tarreau Date: Wed, 11 Mar 2026 17:03:26 +0000 (+0100) Subject: MINOR: activity: support aggregating by caller also for memprofile X-Git-Tag: v3.4-dev7~47 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=892adf3cc1f02bcebe806f1b9889c0d7f0872e33;p=thirdparty%2Fhaproxy.git MINOR: activity: support aggregating by caller also for memprofile "show profiling" supports "aggr" for tasks but it was ignored for memory. Now that we're having many more entries, it makes sense to have it to ignore the call path and merge similar operations. --- diff --git a/src/activity.c b/src/activity.c index c6d8f1795..f03626ce6 100644 --- a/src/activity.c +++ b/src/activity.c @@ -1228,6 +1228,31 @@ static int cli_io_handler_show_profiling(struct appctx *appctx) else qsort(tmp_memstats, MEMPROF_HASH_BUCKETS+1, sizeof(tmp_memstats[0]), cmp_memprof_stats); + if (ctx->aggr) { + /* merge entries for the same caller and reset the exec_ctx */ + for (i = j = 0; i < MEMPROF_HASH_BUCKETS; i++) { + if ((tmp_memstats[i].alloc_calls | tmp_memstats[i].free_calls) == 0) + continue; + for (j = i + 1; j < MEMPROF_HASH_BUCKETS; j++) { + if ((tmp_memstats[j].alloc_calls | tmp_memstats[j].free_calls) == 0) + continue; + if (tmp_memstats[j].caller != tmp_memstats[i].caller || + tmp_memstats[j].method != tmp_memstats[i].method || + tmp_memstats[j].info != tmp_memstats[i].info) + continue; + tmp_memstats[i].locked_calls += tmp_memstats[j].locked_calls; + tmp_memstats[i].alloc_calls += tmp_memstats[j].alloc_calls; + tmp_memstats[i].free_calls += tmp_memstats[j].free_calls; + tmp_memstats[i].alloc_tot += tmp_memstats[j].alloc_tot; + tmp_memstats[i].free_tot += tmp_memstats[j].free_tot; + /* don't dump the ctx */ + tmp_memstats[i].exec_ctx.type = 0; + /* don't dump the merged entry */ + tmp_memstats[j].alloc_calls = tmp_memstats[j].free_calls = 0; + } + } + } + memstats_resume: if (!ctx->linenum) chunk_appendf(&trash,