This is an automated email from the ASF dual-hosted git repository. chengpan pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git
commit 8d55c0b380a5cd2b888af4815013c809d5f8094f Author: zheyan <[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. Authored-by: zheyan <[email protected]> Signed-off-by: Cheng Pan <[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 +
