narenas_ratio: Accept fractional values.

With recent scalability improvements to the HPA, we're experimenting with much
lower arena counts; this gets annoying when trying to test across different
hardware configurations using only the narenas setting.
This commit is contained in:
David Goldblatt 2020-12-01 13:13:55 -08:00 committed by David Goldblatt
parent ecd39418ac
commit d438296b1f

View File

@ -9,6 +9,7 @@
#include "jemalloc/internal/emap.h" #include "jemalloc/internal/emap.h"
#include "jemalloc/internal/extent_dss.h" #include "jemalloc/internal/extent_dss.h"
#include "jemalloc/internal/extent_mmap.h" #include "jemalloc/internal/extent_mmap.h"
#include "jemalloc/internal/fxp.h"
#include "jemalloc/internal/hook.h" #include "jemalloc/internal/hook.h"
#include "jemalloc/internal/jemalloc_internal_types.h" #include "jemalloc/internal/jemalloc_internal_types.h"
#include "jemalloc/internal/log.h" #include "jemalloc/internal/log.h"
@ -127,7 +128,7 @@ bool opt_utrace = false;
bool opt_xmalloc = false; bool opt_xmalloc = false;
bool opt_zero = false; bool opt_zero = false;
unsigned opt_narenas = 0; unsigned opt_narenas = 0;
unsigned opt_narenas_ratio = 4; fxp_t opt_narenas_ratio = FXP_INIT_INT(4);
unsigned ncpus; unsigned ncpus;
@ -1312,10 +1313,14 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
} }
} }
if (CONF_MATCH("narenas_ratio")) { if (CONF_MATCH("narenas_ratio")) {
CONF_HANDLE_UNSIGNED(opt_narenas_ratio, char *end;
"narenas_ratio", 1, UINT_MAX, bool err = fxp_parse(&opt_narenas_ratio, v,
CONF_CHECK_MIN, CONF_DONT_CHECK_MAX, &end);
/* clip */ false) if (err || (size_t)(end - v) != vlen) {
CONF_ERROR("Invalid conf value",
k, klen, v, vlen);
}
CONF_CONTINUE;
} }
if (CONF_MATCH("bin_shards")) { if (CONF_MATCH("bin_shards")) {
const char *bin_shards_segment_cur = v; const char *bin_shards_segment_cur = v;
@ -1877,7 +1882,13 @@ malloc_narenas_default(void) {
* default. * default.
*/ */
if (ncpus > 1) { if (ncpus > 1) {
return ncpus * opt_narenas_ratio; fxp_t fxp_ncpus = FXP_INIT_INT(ncpus);
fxp_t goal = fxp_mul(fxp_ncpus, opt_narenas_ratio);
uint32_t int_goal = fxp_round_nearest(goal);
if (int_goal == 0) {
return 1;
}
return int_goal;
} else { } else {
return 1; return 1;
} }