MINOR: memprof: also report the totals and delta alloc-free
Already had to perform too many additions by external scripts, it's
time to add the totals and delay alloc-free as a last line in the
output of the "show memory profiling".
diff --git a/src/activity.c b/src/activity.c
index 6913a5c..9d697e7 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -512,6 +512,8 @@
struct sched_activity tmp_activity[256] __attribute__((aligned(64)));
#if USE_MEMORY_PROFILING
struct memprof_stats tmp_memstats[MEMPROF_HASH_BUCKETS + 1];
+ unsigned long long tot_alloc_calls, tot_free_calls;
+ unsigned long long tot_alloc_bytes, tot_free_bytes;
#endif
struct stream_interface *si = appctx->owner;
struct buffer *name_buffer = get_trash_chunk();
@@ -652,6 +654,27 @@
return 0;
}
+ tot_alloc_calls = tot_free_calls = tot_alloc_bytes = tot_free_bytes = 0;
+ for (i = 0; i < max_lines; i++) {
+ tot_alloc_calls += tmp_memstats[i].alloc_calls;
+ tot_free_calls += tmp_memstats[i].free_calls;
+ tot_alloc_bytes += tmp_memstats[i].alloc_tot;
+ tot_free_bytes += tmp_memstats[i].free_tot;
+ }
+
+ chunk_appendf(&trash,
+ "-----------------------|-----------------------------|\n"
+ "%11llu %11llu %14llu %14llu| <- Total; Delta_calls=%lld; Delta_bytes=%lld\n",
+ tot_alloc_calls, tot_free_calls,
+ tot_alloc_bytes, tot_free_bytes,
+ tot_alloc_calls - tot_free_calls,
+ tot_alloc_bytes - tot_free_bytes);
+
+ if (ci_putchk(si_ic(si), &trash) == -1) {
+ si_rx_room_blk(si);
+ return 0;
+ }
+
appctx->ctx.cli.i1 = 0; // reset first line to dump
if ((appctx->ctx.cli.i0 & 4) == 0)
appctx->ctx.cli.i0++; // next step