Commit f9ec566
build(docker): default to jemalloc; install mimalloc; add MS jaz java launcher (#35410)
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
- Install both `libjemalloc2` and `libmimalloc2.0` in the runtime image
(`dotCMS/src/main/docker/original/Dockerfile`) and the dev-env image
(`docker/dev-env/Dockerfile`).
- Switch the default `LD_PRELOAD` in `setenv.sh` from mimalloc to
`libjemalloc.so.2`. `LD_PRELOAD` is 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)
- Add Microsoft's apt repo (`packages-microsoft-prod.deb`) and install
`jaz` in the runtime image.
- In `setenv.sh`, default `_RUNJAVA` to `jaz` when present. Tomcat
honors `_RUNJAVA` in place of `$JRE_HOME/bin/java`. `jaz` is a
transparent shim that invokes `java` from `PATH`, adding crash-dump
capture and arg validation.
- Override path: set `_RUNJAVA=/java/bin/java` to bypass `jaz`.
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.
- **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
- [ ] Confirm image builds successfully (`./mvnw install -pl
:dotcms-core -DskipTests` + docker build)
- [ ] Start container and verify `ldd` / `/proc/$PID/maps` on the Tomcat
process shows `libjemalloc.so.2` preloaded
- [ ] Verify both `/usr/lib/<arch>-linux-gnu/libjemalloc.so.2` and
`/usr/lib/<arch>-linux-gnu/libmimalloc.so.2` are present in the final
image
- [ ] Smoke test: run dotCMS, confirm startup is clean and no
allocator-related warnings in logs
- [ ] Verify `LD_PRELOAD=/usr/lib/.../libmimalloc.so.2` override still
works for A/B testing
- [ ] Confirm `jaz` is on `PATH` and Tomcat starts via
`_RUNJAVA=$(command -v jaz)` (check `ps -ef` shows the jaz wrapper)
- [ ] Verify `_RUNJAVA=/java/bin/java` override bypasses jaz cleanly
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 3f0d647 commit f9ec566
3 files changed
Lines changed: 30 additions & 11 deletions
File tree
- docker/dev-env
- dotCMS/src/main
- docker/original
- resources/container/tomcat9/bin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
65 | 69 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
70 | 80 | | |
71 | 81 | | |
72 | 82 | | |
| |||
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
109 | 118 | | |
110 | 119 | | |
111 | 120 | | |
| |||
0 commit comments