From 350809dc5d43ea994de04f7a970b6978a8fec6d2 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Wed, 16 Jan 2019 12:25:24 -0800 Subject: [PATCH] Set huge_threshold to 8M by default. This feature uses an dedicated arena to handle huge requests, which significantly improves VM fragmentation. In production workload we tested it often reduces VM size by >30%. --- include/jemalloc/internal/arena_types.h | 2 +- src/jemalloc.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/jemalloc/internal/arena_types.h b/include/jemalloc/internal/arena_types.h index c40ae6fd..cf07cc02 100644 --- a/include/jemalloc/internal/arena_types.h +++ b/include/jemalloc/internal/arena_types.h @@ -46,6 +46,6 @@ typedef enum { * When allocation_size >= huge_threshold, use the dedicated huge arena (unless * have explicitly spicified arena index). 0 disables the feature. */ -#define HUGE_THRESHOLD_DEFAULT 0 +#define HUGE_THRESHOLD_DEFAULT (8 << 20) #endif /* JEMALLOC_INTERNAL_ARENA_TYPES_H */ diff --git a/src/jemalloc.c b/src/jemalloc.c index 6745df6a..6bfc6133 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1239,7 +1239,14 @@ malloc_conf_init(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS]) { CONF_HANDLE_SSIZE_T(opt_lg_tcache_max, "lg_tcache_max", -1, (sizeof(size_t) << 3) - 1) - /* Experimental feature. Will be documented later.*/ + /* + * The runtime option of huge_threshold remains + * undocumented. It may be tweaked in the next major + * release (6.0). The default value 8M is rather + * conservative / safe. Tuning it further down may + * improve fragmentation a bit more, but may also cause + * contention on the huge arena. + */ CONF_HANDLE_SIZE_T(opt_huge_threshold, "huge_threshold", SC_LARGE_MINCLASS, SC_LARGE_MAXCLASS, yes, yes, false)