From fe4f869f85cc48459ddbceceaf935e56af3b9174 Mon Sep 17 00:00:00 2001 From: levy Date: Tue, 15 Feb 2022 15:22:09 +0800 Subject: [PATCH 1/6] feat: support jemalloc --- rdsn | 2 +- run.sh | 12 +++++++++++- src/build.sh | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/rdsn b/rdsn index 2dd67e0885..89dc34f0ea 160000 --- a/rdsn +++ b/rdsn @@ -1 +1 @@ -Subproject commit 2dd67e0885e36f964633c17afc7d91086517dfaf +Subproject commit 89dc34f0eae30d38bc978601e76117d8ab4d7f4b diff --git a/run.sh b/run.sh index 99ca741a7b..4a24aa9f39 100755 --- a/run.sh +++ b/run.sh @@ -90,6 +90,8 @@ function usage_build() type: address|leak|thread|undefined" echo " --skip_thirdparty whether to skip building thirdparties, default no" echo " --enable_rocksdb_portable build a portable rocksdb binary" + echo " --use_jemalloc build with jemalloc" + } function run_build() { @@ -112,6 +114,7 @@ function run_build() SANITIZER="" TEST_MODULE="" ENABLE_ROCKSDB_PORTABLE=NO + USE_JEMALLOC=NO while [[ $# > 0 ]]; do key="$1" case $key in @@ -169,6 +172,10 @@ function run_build() --disable_gperf) DISABLE_GPERF=YES ;; + --use_jemalloc) + DISABLE_GPERF=YES + USE_JEMALLOC=YES + ;; --skip_thirdparty) SKIP_THIRDPARTY=YES ;; @@ -235,6 +242,9 @@ function run_build() if [ "$ENABLE_ROCKSDB_PORTABLE" == "YES" ]; then OPT="$OPT --enable_rocksdb_portable" fi + if [ "$USE_JEMALLOC" == "YES" ]; then + OPT="$OPT --use_jemalloc" + fi ./run.sh build $OPT --notest if [ $? -ne 0 ]; then echo "ERROR: build rdsn failed" @@ -246,7 +256,7 @@ function run_build() C_COMPILER="$C_COMPILER" CXX_COMPILER="$CXX_COMPILER" BUILD_TYPE="$BUILD_TYPE" \ CLEAR="$CLEAR" PART_CLEAR="$PART_CLEAR" JOB_NUM="$JOB_NUM" \ WARNING_ALL="$WARNING_ALL" ENABLE_GCOV="$ENABLE_GCOV" SANITIZER="$SANITIZER"\ - RUN_VERBOSE="$RUN_VERBOSE" TEST_MODULE="$TEST_MODULE" DISABLE_GPERF="$DISABLE_GPERF" ./build.sh + RUN_VERBOSE="$RUN_VERBOSE" TEST_MODULE="$TEST_MODULE" DISABLE_GPERF="$DISABLE_GPERF" USE_JEMALLOC="$USE_JEMALLOC" ./build.sh if [ $? -ne 0 ]; then echo "ERROR: build pegasus failed" exit 1 diff --git a/src/build.sh b/src/build.sh index cf04663958..aca70f3a93 100755 --- a/src/build.sh +++ b/src/build.sh @@ -93,6 +93,14 @@ else echo "ENABLE_GCOV=NO" fi +if [ "$USE_JEMALLOC" == "YES" ] +then + echo "USE_JEMALLOC=YES" + CMAKE_OPTIONS="$CMAKE_OPTIONS -DUSE_JEMALLOC=ON" +else + echo "USE_JEMALLOC=NO" +fi + if [ ! -z "$SANITIZER" ] then echo "SANITIZER=$SANITIZER" From 2c539885bfede7fea1ab28d68d24134e15ff5b5a Mon Sep 17 00:00:00 2001 From: levy Date: Tue, 15 Feb 2022 15:23:36 +0800 Subject: [PATCH 2/6] fix --- run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/run.sh b/run.sh index 4a24aa9f39..d46c07bdaf 100755 --- a/run.sh +++ b/run.sh @@ -91,7 +91,6 @@ function usage_build() echo " --skip_thirdparty whether to skip building thirdparties, default no" echo " --enable_rocksdb_portable build a portable rocksdb binary" echo " --use_jemalloc build with jemalloc" - } function run_build() { From eabd7d54575c7ce8639021dfab17e0b86d91b8dc Mon Sep 17 00:00:00 2001 From: Dan Wang Date: Fri, 11 Feb 2022 20:49:32 +0800 Subject: [PATCH 3/6] feat: support to use jemalloc --- run.sh | 7 ++++++- scripts/pack_server.sh | 14 +++++++++++++- scripts/pack_tools.sh | 14 +++++++++++++- src/build.sh | 8 ++++++++ src/server/CMakeLists.txt | 6 ++++++ 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/run.sh b/run.sh index d46c07bdaf..922432ad75 100755 --- a/run.sh +++ b/run.sh @@ -181,6 +181,10 @@ function run_build() --enable_rocksdb_portable) ENABLE_ROCKSDB_PORTABLE=YES ;; + --use_jemalloc) + USE_JEMALLOC=YES + DISABLE_GPERF=YES + ;; *) echo "ERROR: unknown option \"$key\"" echo @@ -255,7 +259,8 @@ function run_build() C_COMPILER="$C_COMPILER" CXX_COMPILER="$CXX_COMPILER" BUILD_TYPE="$BUILD_TYPE" \ CLEAR="$CLEAR" PART_CLEAR="$PART_CLEAR" JOB_NUM="$JOB_NUM" \ WARNING_ALL="$WARNING_ALL" ENABLE_GCOV="$ENABLE_GCOV" SANITIZER="$SANITIZER"\ - RUN_VERBOSE="$RUN_VERBOSE" TEST_MODULE="$TEST_MODULE" DISABLE_GPERF="$DISABLE_GPERF" USE_JEMALLOC="$USE_JEMALLOC" ./build.sh + RUN_VERBOSE="$RUN_VERBOSE" TEST_MODULE="$TEST_MODULE" DISABLE_GPERF="$DISABLE_GPERF"\ + USE_JEMALLOC="$USE_JEMALLOC" ./build.sh if [ $? -ne 0 ]; then echo "ERROR: build pegasus failed" exit 1 diff --git a/scripts/pack_server.sh b/scripts/pack_server.sh index 0631bb349c..6871c2602a 100755 --- a/scripts/pack_server.sh +++ b/scripts/pack_server.sh @@ -24,6 +24,7 @@ function usage() { echo " -p|--update-package-template " echo " -g|--custom-gcc" echo " -k|--keytab-file" + echo " -j|--use-jemalloc" exit 0 } @@ -74,6 +75,7 @@ fi custom_gcc="false" keytab_file="" +use_jemalloc="no" while [[ $# > 0 ]]; do option_key="$1" @@ -92,6 +94,9 @@ while [[ $# > 0 ]]; do keytab_file="$2" shift ;; + -j | --use-jemalloc) + use_jemalloc="yes" + ;; esac shift done @@ -102,7 +107,14 @@ copy_file ./DSN_ROOT/lib/libdsn_meta_server.so ${pack}/bin copy_file ./DSN_ROOT/lib/libdsn_replica_server.so ${pack}/bin copy_file ./DSN_ROOT/lib/libdsn_utils.so ${pack}/bin copy_file ./rdsn/thirdparty/output/lib/libPoco*.so.* ${pack}/bin -copy_file ./rdsn/thirdparty/output/lib/libtcmalloc_and_profiler.so.4 ${pack}/bin + +if [ "$use_jemalloc" == "yes" ]; then + copy_file ./rdsn/thirdparty/output/lib/libjemalloc.so.2 ${pack}/bin + copy_file ./rdsn/thirdparty/output/lib/libprofiler.so.0 ${pack}/bin +else + copy_file ./rdsn/thirdparty/output/lib/libtcmalloc_and_profiler.so.4 ${pack}/bin +fi + copy_file ./rdsn/thirdparty/output/lib/libboost*.so.1.69.0 ${pack}/bin copy_file ./rdsn/thirdparty/output/lib/libhdfs* ${pack}/bin copy_file ./rdsn/thirdparty/output/lib/libsasl2.so.3 ${pack}/bin diff --git a/scripts/pack_tools.sh b/scripts/pack_tools.sh index 3e7470508d..1cfcafb25d 100755 --- a/scripts/pack_tools.sh +++ b/scripts/pack_tools.sh @@ -24,6 +24,7 @@ function usage() echo " -h" echo " -p|--update-package-template " echo " -g|--custom-gcc" + echo " -j|--use-jemalloc" exit 0 } @@ -79,6 +80,7 @@ if [ -n "$MINOS_CONFIG_FILE" ]; then fi custom_gcc="false" +use_jemalloc="no" while [[ $# > 0 ]]; do option_key="$1" @@ -93,6 +95,9 @@ while [[ $# > 0 ]]; do -h|--help) usage ;; + -j|--use-jemalloc) + use_jemalloc="yes" + ;; esac shift done @@ -111,7 +116,14 @@ cp -v -r ./DSN_ROOT/bin/pegasus_pressureclient ${pack}/DSN_ROOT/bin/ mkdir -p ${pack}/DSN_ROOT/lib copy_file ./DSN_ROOT/lib/*.so* ${pack}/DSN_ROOT/lib/ copy_file ./rdsn/thirdparty/output/lib/libPoco*.so.* ${pack}/DSN_ROOT/lib/ -copy_file ./rdsn/thirdparty/output/lib/libtcmalloc_and_profiler.so.4 ${pack}/DSN_ROOT/lib/ + +if [ "$use_jemalloc" == "yes" ]; then + copy_file ./rdsn/thirdparty/output/lib/libjemalloc.so.2 ${pack}/DSN_ROOT/lib/ + copy_file ./rdsn/thirdparty/output/lib/libprofiler.so.0 ${pack}/DSN_ROOT/lib/ +else + copy_file ./rdsn/thirdparty/output/lib/libtcmalloc_and_profiler.so.4 ${pack}/DSN_ROOT/lib/ +fi + copy_file ./rdsn/thirdparty/output/lib/libboost*.so.1.69.0 ${pack}/DSN_ROOT/lib/ copy_file ./rdsn/thirdparty/output/lib/libhdfs* ${pack}/DSN_ROOT/lib copy_file ./rdsn/thirdparty/output/lib/libsasl2.so.3 ${pack}/DSN_ROOT/lib/ diff --git a/src/build.sh b/src/build.sh index aca70f3a93..d92047ee46 100755 --- a/src/build.sh +++ b/src/build.sh @@ -119,6 +119,14 @@ else echo "DISABLE_GPERF=NO" fi +if [ "$USE_JEMALLOC" == "YES" ] +then + echo "USE_JEMALLOC=YES" + CMAKE_OPTIONS="$CMAKE_OPTIONS -DUSE_JEMALLOC=ON" +else + echo "USE_JEMALLOC=NO" +fi + CMAKE_OPTIONS="$CMAKE_OPTIONS -DBoost_NO_BOOST_CMAKE=ON -DBOOST_ROOT=${ROOT}/rdsn/thirdparty/output -DBoost_NO_SYSTEM_PATHS=ON" echo "#############################################################################" diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index 4b6c70de62..1b23558f2d 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -50,6 +50,12 @@ set(MY_PROJ_LIBS PocoJSON ) +message(STATUS "USE_JEMALLOC = ${USE_JEMALLOC}") +if(USE_JEMALLOC) + message(STATUS "jemalloc is enabled") + set(MY_PROJ_LIBS JeMalloc::JeMalloc ${MY_PROJ_LIBS}) +endif() + set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini") From 0106993af70838187c82ca8e9ac5e92f1539f999 Mon Sep 17 00:00:00 2001 From: Dan Wang Date: Tue, 15 Feb 2022 15:20:01 +0800 Subject: [PATCH 4/6] feat: support to use jemalloc --- .github/workflows/ci-pull-request.yaml | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/ci-pull-request.yaml b/.github/workflows/ci-pull-request.yaml index 544640ab60..e9f3541248 100644 --- a/.github/workflows/ci-pull-request.yaml +++ b/.github/workflows/ci-pull-request.yaml @@ -62,3 +62,31 @@ jobs: run: | source ./scripts/config_hdfs.sh ./run.sh test --on_travis + + test-with-jemalloc: + name: Test With Jemalloc + needs: lint + runs-on: ubuntu-latest + container: + image: ghcr.io/pegasus-kv/thirdparties-bin:ubuntu1804 + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Unpack prebuilt third-parties + run: unzip /root/thirdparties-bin.zip -d ./rdsn/thirdparty + - name: Compilation + run: ./run.sh build -c --skip_thirdparty --use_jemalloc + - + name: Packaging Server + run: ./run.sh pack_server --use-jemalloc + - + name: Packaging Tools + run: ./run.sh pack_tools --use-jemalloc + - name: Unit Testing + run: | + source ./scripts/config_hdfs.sh + ./run.sh test --on_travis From 5888e0114bf438d25de3e60ab8055c9575470345 Mon Sep 17 00:00:00 2001 From: Dan Wang Date: Tue, 15 Feb 2022 17:10:41 +0800 Subject: [PATCH 5/6] feat: support to use jemalloc --- run.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/run.sh b/run.sh index 922432ad75..9c35ae27c2 100755 --- a/run.sh +++ b/run.sh @@ -171,10 +171,6 @@ function run_build() --disable_gperf) DISABLE_GPERF=YES ;; - --use_jemalloc) - DISABLE_GPERF=YES - USE_JEMALLOC=YES - ;; --skip_thirdparty) SKIP_THIRDPARTY=YES ;; From 0c453621b43faff3895b76a84367771fa23124f7 Mon Sep 17 00:00:00 2001 From: levy Date: Wed, 16 Feb 2022 16:25:18 +0800 Subject: [PATCH 6/6] test --- .github/workflows/ci-pull-request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pull-request.yaml b/.github/workflows/ci-pull-request.yaml index e9f3541248..673f73f7ea 100644 --- a/.github/workflows/ci-pull-request.yaml +++ b/.github/workflows/ci-pull-request.yaml @@ -68,7 +68,7 @@ jobs: needs: lint runs-on: ubuntu-latest container: - image: ghcr.io/pegasus-kv/thirdparties-bin:ubuntu1804 + image: registry.cn-beijing.aliyuncs.com/apachepegasus/thirdparties-bin:ubuntu1804 defaults: run: shell: bash