Skip to content

Commit dd42e42

Browse files
wtarreaucapflam
authored andcommitted
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. (cherry picked from commit 290659f) Signed-off-by: Christopher Faulet <[email protected]>
1 parent e3385b6 commit dd42e42

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

include/haproxy/activity-t.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@
3636

3737

3838
#ifdef USE_MEMORY_PROFILING
39-
/* Elements used by memory profiling. This determines the number of buckets to
40-
* store stats.
41-
*/
42-
#define MEMPROF_HASH_BITS 10
43-
#define MEMPROF_HASH_BUCKETS (1U << MEMPROF_HASH_BITS)
4439

4540
enum memprof_method {
4641
MEMPROF_METH_UNKNOWN = 0,

include/haproxy/defaults.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,14 @@
547547
# define RING_DFLT_QUEUES 6
548548
#endif
549549

550+
/* Elements used by memory profiling. This determines the number of buckets to
551+
* store stats.
552+
*/
553+
#ifndef MEMPROF_HASH_BITS
554+
# define MEMPROF_HASH_BITS 10
555+
#endif
556+
#define MEMPROF_HASH_BUCKETS (1U << MEMPROF_HASH_BITS)
557+
550558
/* Let's make DEBUG_STRICT default to 1 to get rid of it in the makefile */
551559
#ifndef DEBUG_STRICT
552560
# define DEBUG_STRICT 1

0 commit comments

Comments
 (0)