build(docker): install jemalloc + mimalloc; default LD_PRELOAD to jemalloc#35410
build(docker): install jemalloc + mimalloc; default LD_PRELOAD to jemalloc#35410
Conversation
…D to jemalloc Install both libjemalloc2 and libmimalloc2.0 in the runtime and dev-env images, and switch the default LD_PRELOAD in setenv.sh to libjemalloc.so.2. LD_PRELOAD remains overridable at runtime, so operators can still swap back to mimalloc via env var without an image change. Ref: #32320 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @wezell's task in 1m 15s —— View job Review
1. Backtick syntax — export LD_PRELOAD=${LD_PRELOAD:-"/usr/lib/`uname -m`-linux-gnu/libjemalloc.so.2"}The file opens with 2. Duplicate apt-get install -y --no-install-recommends bash zip unzip wget libtcnative-1\
tzdata tini ca-certificates openssl libapr1 libpq-dev curl gnupg\
vim libarchive-tools postgresql-common libmimalloc2.0 libjemalloc2 libarchive-tools
3. Silent failure if path doesn't resolve — If 4. Upgrade path for existing deployments with Operators who pinned Issues 1 and 2 are clean fixes. Issues 3 and 4 are judgment calls, not blockers. |
Installing this for jemalloc's profiling - we can see what is eating off-heap mem when an oom is issued
Summary
libjemalloc2andlibmimalloc2.0in the runtime image (dotCMS/src/main/docker/original/Dockerfile) and the dev-env image (docker/dev-env/Dockerfile).LD_PRELOADinsetenv.shfrom mimalloc tolibjemalloc.so.2.LD_PRELOADis still overridable at runtime, so operators can swap back to mimalloc via env var without an image change.Context: original issue #32320 adopted mimalloc after jemalloc's upstream archival; since then jemalloc has returned to active development, and we want it back as the default while keeping mimalloc installed for easy A/B.
is jemaloc better than minaloc
⏺ No, not in general. They're both excellent and roughly comparable on real workloads.
Raw performance: For pure allocation throughput, mimalloc frequently edges out jemalloc.
Fragmentation / RSS: Roughly a tie. Both are far better than glibc. Mimalloc has a slight theoretical edge on small-object workloads;
Battle-testing on JVMs: jemalloc wins. It's been the de-facto choice for Cassandra, Elasticsearch, Kafka, Hadoop, and countless JVMs
Tooling: jemalloc wins decisively. Its heap profiler is the reason I suggested it — it's the best open-source tool for answering
"what's eating my native memory?" Mimalloc's diagnostics are minimal by comparison.
Ref: #32320
Test plan
./mvnw install -pl :dotcms-core -DskipTests+ docker build)ldd//proc/$PID/mapson the Tomcat process showslibjemalloc.so.2preloaded/usr/lib/<arch>-linux-gnu/libjemalloc.so.2and/usr/lib/<arch>-linux-gnu/libmimalloc.so.2are present in the final imageLD_PRELOAD=/usr/lib/.../libmimalloc.so.2override still works for A/B testing🤖 Generated with Claude Code