From cdcdfa1ea51047b7e4f6e3aea70006afc330fdca Mon Sep 17 00:00:00 2001 From: bigsheeper Date: Tue, 14 Jun 2022 11:12:09 +0800 Subject: [PATCH] Disable jemalloc and use malloc_trim instead (#17538) Signed-off-by: bigsheeper --- build/docker/milvus/centos7/Dockerfile | 1 - build/docker/milvus/ubuntu18.04/Dockerfile | 1 - internal/core/src/segcore/reduce_c.cpp | 6 ++++++ internal/core/thirdparty/CMakeLists.txt | 6 +++--- scripts/start_cluster.sh | 10 ---------- scripts/start_standalone.sh | 10 ---------- 6 files changed, 9 insertions(+), 25 deletions(-) diff --git a/build/docker/milvus/centos7/Dockerfile b/build/docker/milvus/centos7/Dockerfile index b8549f91a2..36e36d67ab 100644 --- a/build/docker/milvus/centos7/Dockerfile +++ b/build/docker/milvus/centos7/Dockerfile @@ -32,7 +32,6 @@ 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 b9c387a3e1..2480cc92b9 100644 --- a/build/docker/milvus/ubuntu18.04/Dockerfile +++ b/build/docker/milvus/ubuntu18.04/Dockerfile @@ -32,7 +32,6 @@ 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/internal/core/src/segcore/reduce_c.cpp b/internal/core/src/segcore/reduce_c.cpp index 19828867d4..f7cfa7af7d 100644 --- a/internal/core/src/segcore/reduce_c.cpp +++ b/internal/core/src/segcore/reduce_c.cpp @@ -9,6 +9,9 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations under the License +#ifndef __APPLE__ +#include +#endif #include #include "Reduce.h" #include "common/CGoHelper.h" @@ -83,4 +86,7 @@ DeleteSearchResultDataBlobs(CSearchResultDataBlobs cSearchResultDataBlobs) { } auto search_result_data_blobs = reinterpret_cast(cSearchResultDataBlobs); delete search_result_data_blobs; +#ifdef __linux__ + malloc_trim(0); +#endif } diff --git a/internal/core/thirdparty/CMakeLists.txt b/internal/core/thirdparty/CMakeLists.txt index c2d298107f..4ab3100d01 100644 --- a/internal/core/thirdparty/CMakeLists.txt +++ b/internal/core/thirdparty/CMakeLists.txt @@ -70,6 +70,6 @@ if ( LINUX OR APPLE) endif() # ******************************* Thridparty jemalloc ******************************** -if ( LINUX ) - add_subdirectory( jemalloc ) -endif() \ No newline at end of file +#if ( LINUX ) +# add_subdirectory( jemalloc ) +#endif() \ No newline at end of file diff --git a/scripts/start_cluster.sh b/scripts/start_cluster.sh index 042dc8f2e7..a3b626cc3c 100755 --- a/scripts/start_cluster.sh +++ b/scripts/start_cluster.sh @@ -16,16 +16,6 @@ # 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 31732ba0d3..931cc7c322 100755 --- a/scripts/start_standalone.sh +++ b/scripts/start_standalone.sh @@ -16,15 +16,5 @@ # 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 &