From 4cb01d5813655e463689930a7b524cd2a56e463e Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 12 Jan 2022 17:03:59 -0600 Subject: [PATCH] docker: set MALLOC_CONF in docker image. Set the MALLOC_CONF environment variable in the Docker image to tune the Jemalloc configuration. Configuring Jemalloc to use two memory arenas reduces memory fragmentation, and using background threads and low decay times allows freed memory to be returned to the OS sooner. Previously we set this environment variable at runtime in Kubernetes, but baking it into the image is simpler. --- config/docker/Dockerfile.danbooru | 1 + 1 file changed, 1 insertion(+) diff --git a/config/docker/Dockerfile.danbooru b/config/docker/Dockerfile.danbooru index 746eb4d4e..9e203e696 100644 --- a/config/docker/Dockerfile.danbooru +++ b/config/docker/Dockerfile.danbooru @@ -61,6 +61,7 @@ RUN \ FROM base as production ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 +ENV MALLOC_CONF=background_thread:true,narenas:2,dirty_decay_ms:1000,muzzy_decay_ms:0,tcache:false COPY --from=development /root /root COPY --from=development /danbooru /danbooru