0

I have a Redis cluster that is constantly at a memory fragmentation ratio of about 2.

I was trying to enable activedefrag by running CONFIG SET activedefrag yes in redis-cli, but I received the error message:

(error) ERR Invalid argument 'yes' for CONFIG SET 'activedefrag' - Active defragmentation cannot be enabled: it requires a Redis server compiled with a modified Jemalloc like the one shipped by default with the Redis source distribution

The redis-server package shipped with Ubuntu 22.04 is 6.0 and the version string looks like it was compiled with jemalloc.

# redis-server --version Redis server v=6.0.16 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=a3fdef44459b3ad6 

ldd confirms that it is linked to libjemalloc.

# ldd `which redis-server` ... libjemalloc.so.2 => /lib/x86_64-linux-gnu/libjemalloc.so.2 (0x00007f0428b26000) 

When setting the option in the config file redis-server fails to start with a similar error message.

Is there any option I am missing or do I need to compile Redis myself to be able to use defragmentation? I could not find any configuration option to "enable" jemalloc.

1 Answer 1

1

I started a docker container with the official redis:6.0 image and here the setting works, and the version string looks basically identical.

root@42613c835e31:/data# redis-server --version Redis server v=6.0.19 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=3aa1eb72f68fbe5e root@42613c835e31:/data# redis-cli 127.0.0.1:6379> CONFIG SET activedefrag yes OK 

But ldd shows that it is NOT linked to a jemalloc library:

root@42613c835e31:/data# ldd `which redis-server` linux-vdso.so.1 (0x00007ffe4a9a2000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5b6aa41000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5b6aa3b000) libssl.so.1.1 => /usr/lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f5b6a9a8000) libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f5b6a6b3000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5b6a691000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5b6a4bd000) /lib64/ld-linux-x86-64.so.2 (0x00007f5b6afa2000) 

It looks like the Ubuntu package is NOT compiled with the needed modified jemalloc library, but uses the Ubuntu default instead.

So the only options I currently see are:

The package from the Redis repo is compiled with the modified jemalloc, the activedefrag config works with it. This seems to be the most promising option, as updates will be handled automatically with regular system updates. I'll try to switch from the Ubuntu package to it next.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.