build(docker): default to jemalloc; install mimalloc; add MS jaz java launcher#35410
build(docker): default to jemalloc; install mimalloc; add MS jaz java launcher#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 27s —— View job PR Review
Issues1. No integrity check on the Microsoft
wget -q "https://packages.microsoft.com/config/ubuntu/$(. /etc/os-release; echo $VERSION_ID)/packages-microsoft-prod.deb" -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \The 2.
apt-get install -y --no-install-recommends \
postgresql-client-18 \
jaz && \
3. Dev/prod parity gap —
4.
The PR touched this line but didn't remove the duplicate. Harmless but worth fixing while the line is open. Fix this → 5.
if [ -z "$_RUNJAVA" ] && command -v jaz >/dev/null 2>&1; then
export _RUNJAVA="$(command -v jaz)"
fiMinor: The allocator switch (jemalloc → default, mimalloc kept) and the |
Install Microsoft's Azure Command Launcher for Java (jaz) in the runtime Dockerfile alongside the existing postgres-client. jaz is a transparent shim over `java` that adds crash-dump capture and arg validation. In setenv.sh, set _RUNJAVA to jaz when present so Tomcat invokes it in place of $JRE_HOME/bin/java. _RUNJAVA remains overridable at runtime, so operators can bypass jaz by setting _RUNJAVA=/java/bin/java. Ref: #32320 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The first apt install block lost its cleanup when the postgresql-common install was consolidated, so apt lists were being baked into the layer. Re-append && rm -rf /var/lib/apt/lists/* to that RUN. Ref: #32320 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… install Address PR review feedback by collapsing the postgres/jaz install steps into a single RUN block: - Remove packages-microsoft-prod.deb after dpkg install instead of leaving it in the image layer. - Install postgresql-common in the same RUN where it is purged so it is not baked into intermediate layers. - Drop apt-get update cache (rm -rf /var/lib/apt/lists/*) inside the same RUN where update was issued, instead of a later layer. - Strip extraneous blank lines. No functional change to the resulting image (same packages installed, same purges); just smaller layers and tighter cleanup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Installing jemalloc for its profiling — we can see what is eating off-heap mem when an OOM is issued.
Summary
This PR bundles two related runtime-image changes:
1. Allocator: jemalloc as default, mimalloc still installed
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.
2. JVM launcher: Microsoft
jaz(Azure Command Launcher for Java)packages-microsoft-prod.deb) and installjazin the runtime image.setenv.sh, default_RUNJAVAtojazwhen present. Tomcat honors_RUNJAVAin place of$JRE_HOME/bin/java.jazis a transparent shim that invokesjavafromPATH, adding crash-dump capture and arg validation._RUNJAVA=/java/bin/javato bypassjaz.Both changes target diagnostics for native memory and JVM crashes — the same problem space — which is why they ship together. Either piece can be disabled at runtime without rebuilding.
why jemalloc over mimalloc
No clear winner in general. They're both excellent and roughly comparable on real workloads.
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 testingjazis onPATHand Tomcat starts via_RUNJAVA=$(command -v jaz)(checkps -efshows the jaz wrapper)_RUNJAVA=/java/bin/javaoverride bypasses jaz cleanly🤖 Generated with Claude Code
This PR fixes: #32320