Repository navigation
Install a 4 KiB-page jemalloc on every architecture so arm64 TaskManagers stop getting OOMKilled - #415
Closed
velo wants to merge 5 commits into
Closed
Install a 4 KiB-page jemalloc on every architecture so arm64 TaskManagers stop getting OOMKilled#415velo wants to merge 5 commits into
velo wants to merge 5 commits into
Conversation
…MKilled Signed-off-by: Marvin Froeder <marvin@datasqrl.com>
…itecture Signed-off-by: Marvin Froeder <marvin@datasqrl.com>
…ner-base image and skip redundant work in the Docker job Signed-off-by: Marvin Froeder <marvin@datasqrl.com>
…e Docker image job Signed-off-by: Marvin Froeder <marvin@datasqrl.com>
Signed-off-by: Marvin Froeder <marvin@datasqrl.com>
Collaborator
Author
|
Not proceeding: we'll handle the extra native memory in cloud-compilation sizing (drop Flink's JVM share from 90% to 80% when the CPU limit is more than 2x the request) instead of shipping a custom jemalloc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since prod moved to arm64 (Graviton
r6gd) on 2026-10-14, the metrics2 TaskManagers get OOMKilled (exit 137) every 1 to 4.5 hours. On amd64m5ad, the same job ran for days without a kill.The cause is jemalloc. The Flink base image installs Ubuntu's
libjemalloc2, and our entrypoint preloads it. On arm64 that package is compiled for 64 KiB pages so one binary also runs on 64K-page kernels. Our nodes run 4 KiB-page kernels:m5ad.2xlarge)r6gd.xlarge)Page sizegetconf PAGESIZEWith 64 KiB pages, every jemalloc slab and extent is rounded to 64 KiB, and dirty memory is purged in 64 KiB units. A TaskManager with ~290 RocksDB instances and ~3.5k threads pays for that in resident memory that Flink's memory model doesn't account for.
Same job, image and config, measured from
/proc/1/smaps: the malloc'd region was ~3.3 GiB on ARM against 2.5–2.8 GiB on x86 during its first 40 minutes. That's roughly 500–800 MiB more on ARM, against a JVM overhead budget of 799 MiB. Thread stacks were identical (~380 MiB on both), so the 2 MiB default stack size on aarch64 doesn't matter.Mate found the same 64 KiB page size independently.
Change
jemalloc-4kbuilder stage. It builds jemalloc 5.3.0 with--with-lg-page=12and verifies the tarball's SHA-256./usr/lib/<arch>-linux-gnu/libjemalloc.so.2on every architecture. The Flink operator starts pods with the upstream/docker-entrypoint.sh, not our/entrypoint.sh, so choosing a library in a script would be skipped in prod. Replacing the file both entrypoints preload makes the choice independent of the entrypoint, and amd64 and arm64 run the same allocator.Version: "5.3.0-…"andPage size: 4096when preloaded.adr/fix-jemalloc-arm64-page-size.mddocuments the ARM issue, the evidence, the decisions, and how to verify a running TaskManager.DISABLE_JEMALLOC=truestill works as an escape hatch, and it's required on 64K-page kernels, where a 4 KiB-page jemalloc won't start.Testing
/docker-entrypoint.shpreloads the replaced 4 KiB library (confirmed in/proc/self/maps).mvn testfor the flink-sql-runner module passes.32c6a0744on arm64 and compare its memory with the current image.