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

zhouky pushed a commit to branch branch-0.3
in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git


The following commit(s) were added to refs/heads/branch-0.3 by this push:
     new 79b091413 [CELEBORN-900] Prefer to use jemalloc for memory allocation
79b091413 is described below

commit 79b091413df921d78d233f5a1596bbbd47fbb613
Author: Cheng Pan <[email protected]>
AuthorDate: Fri Sep 8 19:33:24 2023 +0800

    [CELEBORN-900] Prefer to use jemalloc for memory allocation
    
    ### What changes were proposed in this pull request?
    
    Only the Dockfile needs to change in this pr.
    
    ### Why are the changes needed?
    
    When deploying celeborn for flink on kubernetes, Introducing jemalloc can 
improve pod memory usage.
    
    ### Does this PR introduce _any_ user-facing change?
    None
    
    ### How was this patch tested?
    Maybe starting a production job to test the memory usage improvement is 
needed.
    
    Closes #1824 from mddxhj/feature/introduce_jemalloc.
    
    Lead-authored-by: Cheng Pan <[email protected]>
    Co-authored-by: zheyan <[email protected]>
    Signed-off-by: zky.zhoukeyong <[email protected]>
    (cherry picked from commit 3f4c43b04bc2cdd48778bd1a76b63c91172f5523)
    Signed-off-by: zky.zhoukeyong <[email protected]>
---
 conf/celeborn-env.sh.template |  3 ++-
 docker/Dockerfile             |  2 +-
 sbin/load-celeborn-env.sh     | 21 +++++++++++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/conf/celeborn-env.sh.template b/conf/celeborn-env.sh.template
index f9951f81e..bada8c172 100755
--- a/conf/celeborn-env.sh.template
+++ b/conf/celeborn-env.sh.template
@@ -31,4 +31,5 @@
 # CELEBORN_WORKER_JAVA_OPTS="-XX:-PrintGC -XX:+PrintGCDetails 
-XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:gc-worker.out 
-Dio.netty.leakDetectionLevel=advanced"
 # CELEBORN_MASTER_JAVA_OPTS="-XX:-PrintGC -XX:+PrintGCDetails 
-XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:gc-master.out 
-Dio.netty.leakDetectionLevel=advanced"
 # CELEBORN_PID_DIR="$CELEBORN_HOME/pids"
-# CELEBORN_LOG_DIR="$CELEBORN_HOME/logs"
\ No newline at end of file
+# CELEBORN_LOG_DIR="$CELEBORN_HOME/logs"
+# DISABLE_JEMALLOC="false"
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 3a81c2ee9..17a4e0592 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -26,7 +26,7 @@ ENV 
PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
 
 RUN set -ex && \
     apt-get update && \
-    apt-get install -y bash tini busybox bind9-utils telnet net-tools procps 
krb5-user dnsutils && \
+    apt-get install -y bash tini busybox bind9-utils telnet net-tools procps 
krb5-user dnsutils libjemalloc-dev && \
     ln -snf /bin/bash /bin/sh && \
     rm -rf /var/cache/apt/* && \
     mkdir /opt/busybox && \
diff --git a/sbin/load-celeborn-env.sh b/sbin/load-celeborn-env.sh
index df1001b3b..9a36e1f36 100755
--- a/sbin/load-celeborn-env.sh
+++ b/sbin/load-celeborn-env.sh
@@ -69,3 +69,24 @@ if [ "$CELEBORN_PID_DIR" = "" ]; then
   export CELEBORN_PID_DIR="${CELEBORN_HOME}/pids"
 fi
 
+# jemalloc memory allocator is enabled by default, you may set 
DISABLE_JEMALLOC to true in celeborn-env.sh if it's not as you wish.
+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
+

Reply via email to