From 290659ffd3a2eead918adc387e8842c59fbff2e7 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 27 Jun 2024 17:53:18 +0200 Subject: [PATCH] MINOR: activity: make the memory profiling hash size configurable at build time The MEMPROF_HASH_BITS variable was set to 10 without a possibility to change it (beyond patching the code). After seeing a few reports already with "other" being listed and a list with close to 1024 entries, it looks like it's about time to either increase the hash size, or at least make it configurable for special cases. As a reminder, in order to remain fast, the algorithm searches no more than 16 places after the hash, so when a table is almost full, searches are long and new places are rare. The present patch just makes it possible to redefine it by passing "-DMEMPROF_HASH_BITS=11" or "-DMEMPROF_HASH_BITS=12" in CFLAGS, and moves the definition to defaults.h to make it easier to find. Such values should be way sufficient for the vast majority of use cases. Maybe in the future we'd change the default. At least this version should be backported to ease rebuilds, say, till 2.8 or so. --- include/haproxy/activity-t.h | 5 ----- include/haproxy/defaults.h | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/haproxy/activity-t.h b/include/haproxy/activity-t.h index 9faeecdb3..82666d305 100644 --- a/include/haproxy/activity-t.h +++ b/include/haproxy/activity-t.h @@ -36,11 +36,6 @@ #ifdef USE_MEMORY_PROFILING -/* Elements used by memory profiling. This determines the number of buckets to - * store stats. - */ -#define MEMPROF_HASH_BITS 10 -#define MEMPROF_HASH_BUCKETS (1U << MEMPROF_HASH_BITS) enum memprof_method { MEMPROF_METH_UNKNOWN = 0, diff --git a/include/haproxy/defaults.h b/include/haproxy/defaults.h index eda346aa2..73e8e0c92 100644 --- a/include/haproxy/defaults.h +++ b/include/haproxy/defaults.h @@ -547,6 +547,14 @@ # define RING_DFLT_QUEUES 6 #endif +/* Elements used by memory profiling. This determines the number of buckets to + * store stats. + */ +#ifndef MEMPROF_HASH_BITS +# define MEMPROF_HASH_BITS 10 +#endif +#define MEMPROF_HASH_BUCKETS (1U << MEMPROF_HASH_BITS) + /* Let's make DEBUG_STRICT default to 1 to get rid of it in the makefile */ #ifndef DEBUG_STRICT # define DEBUG_STRICT 1