Set jemalloc LD_PRELOAD env to linux image (#17494)

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
pull/17501/head
bigsheeper 2022-06-10 21:58:08 +08:00 committed by GitHub
parent 36ad989590
commit c77bc81057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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..."

View File

@ -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 &