From 004ba37436819063a19a42ac764ee62c76a737a4 Mon Sep 17 00:00:00 2001 From: bigsheeper Date: Thu, 11 Aug 2022 19:50:37 +0800 Subject: [PATCH] Set LD_PRELOAD env for jemalloc (#18612) Signed-off-by: bigsheeper Signed-off-by: bigsheeper --- build/docker/milvus/centos7/Dockerfile | 1 + build/docker/milvus/ubuntu18.04/Dockerfile | 1 + scripts/start_cluster.sh | 10 ++++++++++ scripts/start_standalone.sh | 10 ++++++++++ 4 files changed, 22 insertions(+) diff --git a/build/docker/milvus/centos7/Dockerfile b/build/docker/milvus/centos7/Dockerfile index 36e36d67ab..b8549f91a2 100644 --- a/build/docker/milvus/centos7/Dockerfile +++ b/build/docker/milvus/centos7/Dockerfile @@ -32,6 +32,7 @@ COPY ./lib/ /milvus/lib/ ENV PATH=/milvus/bin:$PATH ENV LD_LIBRARY_PATH=/milvus/lib:$LD_LIBRARY_PATH:/usr/lib +ENV LD_PRELOAD=/milvus/lib/libjemalloc.so # Add Tini ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini /tini diff --git a/build/docker/milvus/ubuntu18.04/Dockerfile b/build/docker/milvus/ubuntu18.04/Dockerfile index 2480cc92b9..b9c387a3e1 100644 --- a/build/docker/milvus/ubuntu18.04/Dockerfile +++ b/build/docker/milvus/ubuntu18.04/Dockerfile @@ -32,6 +32,7 @@ COPY ./lib/ /milvus/lib/ ENV PATH=/milvus/bin:$PATH ENV LD_LIBRARY_PATH=/milvus/lib:$LD_LIBRARY_PATH:/usr/lib +ENV LD_PRELOAD=/milvus/lib/libjemalloc.so # Add Tini ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini /tini diff --git a/scripts/start_cluster.sh b/scripts/start_cluster.sh index a3b626cc3c..042dc8f2e7 100755 --- a/scripts/start_cluster.sh +++ b/scripts/start_cluster.sh @@ -16,6 +16,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + LIBJEMALLOC=$PWD/internal/core/output/lib/libjemalloc.so + if test -f "$LIBJEMALLOC"; then + #echo "Found $LIBJEMALLOC" + export LD_PRELOAD="$LIBJEMALLOC" + else + echo "WARN: Cannot find $LIBJEMALLOC" + fi +fi + echo "Starting rootcoord..." nohup ./bin/milvus run rootcoord > /tmp/rootcoord.log 2>&1 & diff --git a/scripts/start_standalone.sh b/scripts/start_standalone.sh index 931cc7c322..31732ba0d3 100755 --- a/scripts/start_standalone.sh +++ b/scripts/start_standalone.sh @@ -16,5 +16,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + LIBJEMALLOC=$PWD/internal/core/output/lib/libjemalloc.so + if test -f "$LIBJEMALLOC"; then + #echo "Found $LIBJEMALLOC" + export LD_PRELOAD="$LIBJEMALLOC" + else + echo "WARN: Cannot find $LIBJEMALLOC" + fi +fi + echo "Starting standalone..." nohup ./bin/milvus run standalone > /tmp/standalone.log 2>&1 &