This is an automated email from the ASF dual-hosted git repository.

gaborgsomogyi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 8b789eeb [FLINK-35192] support jemalloc in image
8b789eeb is described below

commit 8b789eeb0139bc491858cc0189e09512c1a73ed1
Author: chenyuzhi459 <553673...@qq.com>
AuthorDate: Tue May 21 14:22:35 2024 +0800

    [FLINK-35192] support jemalloc in image
---
 Dockerfile           |  8 ++++++++
 docker-entrypoint.sh | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/Dockerfile b/Dockerfile
index ac516aeb..7dc05a66 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -64,6 +64,14 @@ ARG SKIP_OS_UPDATE=true
 RUN if [ "$SKIP_OS_UPDATE" = "false" ]; then apt-get update; fi
 RUN if [ "$SKIP_OS_UPDATE" = "false" ]; then apt-get upgrade -y; fi
 
+ARG DISABLE_JEMALLOC=false
+# Install jemalloc
+RUN if [ "$DISABLE_JEMALLOC" = "false" ]; then \
+  apt-get update; \
+  apt-get -y install libjemalloc-dev; \
+  rm -rf /var/lib/apt/lists/*; \
+  fi
+
 USER flink
 ENTRYPOINT ["/docker-entrypoint.sh"]
 CMD ["help"]
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 3343f2d6..7464645e 100755
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -22,6 +22,27 @@ args=("$@")
 
 cd /flink-kubernetes-operator || exit
 
+maybe_enable_jemalloc() {
+    if [ "${DISABLE_JEMALLOC:-false}" = "false" ]; then
+        JEMALLOC_PATH="/usr/lib/$(uname -m)-linux-gnu/libjemalloc.so"
+        JEMALLOC_FALLBACK="/usr/lib/x86_64-linux-gnu/libjemalloc.so"
+        if [ -f "$JEMALLOC_PATH" ]; then
+            export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_PATH
+        elif [ -f "$JEMALLOC_FALLBACK" ]; then
+            export LD_PRELOAD=$LD_PRELOAD:$JEMALLOC_FALLBACK
+        else
+            if [ "$JEMALLOC_PATH" = "$JEMALLOC_FALLBACK" ]; then
+                MSG_PATH=$JEMALLOC_PATH
+            else
+                MSG_PATH="$JEMALLOC_PATH and $JEMALLOC_FALLBACK"
+            fi
+            echo "WARNING: attempted to load jemalloc from $MSG_PATH but the 
library couldn't be found. glibc will be used instead."
+        fi
+    fi
+}
+
+maybe_enable_jemalloc
+
 if [ "$1" = "help" ]; then
     printf "Usage: $(basename "$0") (operator|webhook)\n"
     printf "    Or $(basename "$0") help\n\n"

Reply via email to