I am trying to set some tunables for jemalloc
at runtime, before launching Redis.
http://jemalloc.net/jemalloc.3.html#tuning : Says that I can set the environment variable MALLOC_CONF
. This is how I am doing that.
I run export MALLOC_CONF=narenas:40
in my shell, then I launch the redis-server like so ./src/redis-server --port 8088
However, if I connect to this redis server using the redis-cli and run MEMORY MALLOC-STATS
I see this output:
___ Begin jemalloc statistics ___
Version: "5.3.0-0-g0"
Build-time option settings
config.cache_oblivious: false
config.debug: false
config.fill: true
config.lazy_lock: false
config.malloc_conf: ""
config.opt_safety_checks: false
config.prof: false
config.prof_libgcc: false
config.prof_libunwind: false
config.stats: true
config.utrace: false
config.xmalloc: false
Run-time option settings
opt.abort: false
opt.abort_conf: false
opt.cache_oblivious: false
opt.confirm_conf: false
opt.retain: true
opt.dss: "secondary"
opt.narenas: 160
[... output continues]
Clearly the narenas
parameter is still set to its default value.
Am I completely misunderstanding how to set the value of this env variable?
I expected the value of opt.narenas
to be set to 40 not 160
2
Answers
So it turns out that when you build redis on my system, it sets
--with-jemalloc-prefix=je_
, which means that all of jemalloc's public APIs become prefixed with the stringje_
(orJE_
)Running
export JE_MALLOC_CONF=narenas:40
then results in the expected behavior.The prefix behavior is described here : https://github.com/jemalloc/jemalloc/blob/dev/INSTALL.md
These are compile time flags, you have to rebuild jemalloc with these flags. One way is to add in deps/Makefile
Also, make sure you clean prev build, with
make distclean