From 81e6985122a793ba4c74f12bdfebaafb082be6c0 Mon Sep 17 00:00:00 2001 From: Jordan Gonzalez <30836115+duncanista@users.noreply.github.com> Date: Tue, 23 Jun 2026 22:46:21 -0400 Subject: [PATCH] perf(build): set jemalloc narenas:1 to trim init metadata + RSS tikv-jemallocator links jemalloc with the _rjem_ symbol prefix, so a runtime MALLOC_CONF env var is never read. Set the compile-time JEMALLOC_SYS_WITH_MALLOC_CONF instead, in both the GNU and Alpine compile Dockerfiles. A single arena reduces the metadata jemalloc maps at init and lowers RSS; the extension is not allocation-throughput-bound, so arena contention is not a concern. Dockerfile-only change; not docker-built locally and pending benchmarking. --- images/Dockerfile.bottlecap.alpine.compile | 5 +++++ images/Dockerfile.bottlecap.compile | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/images/Dockerfile.bottlecap.alpine.compile b/images/Dockerfile.bottlecap.alpine.compile index 9858c5662..c7770ce73 100644 --- a/images/Dockerfile.bottlecap.alpine.compile +++ b/images/Dockerfile.bottlecap.alpine.compile @@ -24,6 +24,11 @@ ENV PATH="${PATH}:/root/.cargo/bin" # Build the binary ENV RUSTFLAGS="-Cpanic=abort" +# tikv-jemallocator uses the `_rjem_` symbol prefix, so the runtime MALLOC_CONF +# env var is ignored. Tune jemalloc at compile time instead: a single arena +# reduces metadata mapped at init and lowers RSS (the extension is not +# allocation-throughput-bound, so arena contention is a non-issue here). +ENV JEMALLOC_SYS_WITH_MALLOC_CONF="narenas:1" WORKDIR /tmp/dd/bottlecap RUN --mount=type=cache,target=/root/.cargo/git \ diff --git a/images/Dockerfile.bottlecap.compile b/images/Dockerfile.bottlecap.compile index 12a23f64b..f2007c6fd 100644 --- a/images/Dockerfile.bottlecap.compile +++ b/images/Dockerfile.bottlecap.compile @@ -23,6 +23,11 @@ ENV PATH="${PATH}:/root/.cargo/bin" # Build the binary ENV RUSTFLAGS="-Cpanic=abort" +# tikv-jemallocator uses the `_rjem_` symbol prefix, so the runtime MALLOC_CONF +# env var is ignored. Tune jemalloc at compile time instead: a single arena +# reduces metadata mapped at init and lowers RSS (the extension is not +# allocation-throughput-bound, so arena contention is a non-issue here). +ENV JEMALLOC_SYS_WITH_MALLOC_CONF="narenas:1" ENV AWS_LC_FIPS_SYS_CC=clang ENV AWS_LC_FIPS_SYS_CXX=clang++