diff --git a/build/docker/milvus/centos7/Dockerfile b/build/docker/milvus/centos7/Dockerfile index 36e36d67ab520e02d7cab16afe31c3783cf99f4b..b8549f91a23bf87ea01d49bdf3b2cfd11a7c3b9c 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 2480cc92b9f89d79c4cfc2449e52b7a319d00ea3..b9c387a3e164d4b061255d12dafbaf0ea43ea190 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/cmd/roles/roles.go b/cmd/roles/roles.go index aaaf582b8b1019acd474b8ad5867ee8d8a1f132d..c02544b50f95da8485e68ff6808d676149ea9a1b 100644 --- a/cmd/roles/roles.go +++ b/cmd/roles/roles.go @@ -90,6 +90,14 @@ func (mr *MilvusRoles) EnvValue(env string) bool { return env == "1" || env == "true" } +func (mr *MilvusRoles) printLDPreLoad() { + const LDPreLoad = "LD_PRELOAD" + val, ok := os.LookupEnv(LDPreLoad) + if ok { + log.Info("Enable Jemalloc", zap.String("Jemalloc Path", val)) + } +} + func (mr *MilvusRoles) runRootCoord(ctx context.Context, localMsg bool) *components.RootCoord { var rc *components.RootCoord var wg sync.WaitGroup @@ -349,6 +357,7 @@ func (mr *MilvusRoles) runIndexNode(ctx context.Context, localMsg bool, alias st func (mr *MilvusRoles) Run(local bool, alias string) { log.Info("starting running Milvus components") ctx, cancel := context.WithCancel(context.Background()) + mr.printLDPreLoad() // only standalone enable localMsg if local { diff --git a/scripts/start_cluster.sh b/scripts/start_cluster.sh index db3a6ffb7ecf2ad79090990515a13a9dd94eb742..042dc8f2e731148754d39701e31d945ea6380f08 100755 --- a/scripts/start_cluster.sh +++ b/scripts/start_cluster.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Licensed to the LF AI & Data foundation under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -14,14 +16,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - LIBJEMALLOC=$PWD/internal/core/output/lib/libjemalloc.so - if test -f "$LIBJEMALLOC"; then - #echo "Found $LIBJEMALLOC" - export LD_PRELDOAD="$LIBJEMALLOC" - else - echo "WARN: Cannot find $LIBJEMALLOC" - fi +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..." diff --git a/scripts/start_standalone.sh b/scripts/start_standalone.sh index 98bb1a694a8e64ccd8779fa191312b4ff69ab9ea..31732ba0d34a8684aa2929e93a3fe020855d25f1 100755 --- a/scripts/start_standalone.sh +++ b/scripts/start_standalone.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Licensed to the LF AI & Data foundation under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -14,16 +16,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then +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" - echo export LD_PRELOAD="$LIBJEMALLOC" else - echo "WARN: Cannot find $LIBJEMALLOC" + echo "WARN: Cannot find $LIBJEMALLOC" fi -fi +fi echo "Starting standalone..." nohup ./bin/milvus run standalone > /tmp/standalone.log 2>&1 &