Skip to content

Commit

Permalink
feat: support to use jemalloc for building pegasus (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
empiredan authored Jul 19, 2022
1 parent 07bbf4d commit 785b3b7
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 6 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ if(ENABLE_GPERF AND USE_JEMALLOC)
endif()

if(USE_JEMALLOC)
message(STATUS "jemalloc is enabled")
set(JEMALLOC_LIB_TYPE "SHARED")
endif()

Expand Down
5 changes: 3 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ function run_build()
cd $ROOT/src
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
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
if [ $? -ne 0 ]; then
echo "ERROR: build pegasus failed"
exit 1
Expand Down
6 changes: 6 additions & 0 deletions scripts/pack_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ while [[ $# > 0 ]]; do
-h|--help)
usage
;;
*)
echo "ERROR: unknown option \"$option_key\""
echo
usage
exit 1
;;
esac
shift
done
Expand Down
20 changes: 19 additions & 1 deletion scripts/pack_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function usage() {
echo " -p|--update-package-template <minos-package-template-file-path>"
echo " -g|--custom-gcc"
echo " -k|--keytab-file"
echo " -j|--use-jemalloc"
exit 0
}

Expand Down Expand Up @@ -74,6 +75,7 @@ fi

custom_gcc="false"
keytab_file=""
use_jemalloc="off"

while [[ $# > 0 ]]; do
option_key="$1"
Expand All @@ -92,6 +94,15 @@ while [[ $# > 0 ]]; do
keytab_file="$2"
shift
;;
-j | --use-jemalloc)
use_jemalloc="on"
;;
*)
echo "ERROR: unknown option \"$option_key\""
echo
usage
exit 1
;;
esac
shift
done
Expand All @@ -102,7 +113,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 ./thirdparty/output/lib/libPoco*.so.* ${pack}/bin
copy_file ./thirdparty/output/lib/libtcmalloc_and_profiler.so.4 ${pack}/bin

if [ "$use_jemalloc" == "on" ]; then
copy_file ./thirdparty/output/lib/libjemalloc.so.2 ${pack}/bin
copy_file ./thirdparty/output/lib/libprofiler.so.0 ${pack}/bin
else
copy_file ./thirdparty/output/lib/libtcmalloc_and_profiler.so.4 ${pack}/bin
fi

copy_file ./thirdparty/output/lib/libboost*.so.1.69.0 ${pack}/bin
copy_file ./thirdparty/output/lib/libhdfs* ${pack}/bin
copy_file ./thirdparty/output/lib/libsasl*.so.* ${pack}/bin
Expand Down
20 changes: 19 additions & 1 deletion scripts/pack_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function usage()
echo " -h"
echo " -p|--update-package-template <minos-package-template-file-path>"
echo " -g|--custom-gcc"
echo " -j|--use-jemalloc"
exit 0
}

Expand Down Expand Up @@ -79,6 +80,7 @@ if [ -n "$MINOS_CONFIG_FILE" ]; then
fi

custom_gcc="false"
use_jemalloc="off"

while [[ $# > 0 ]]; do
option_key="$1"
Expand All @@ -93,6 +95,15 @@ while [[ $# > 0 ]]; do
-h|--help)
usage
;;
-j|--use-jemalloc)
use_jemalloc="on"
;;
*)
echo "ERROR: unknown option \"$option_key\""
echo
usage
exit 1
;;
esac
shift
done
Expand All @@ -111,7 +122,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 ./thirdparty/output/lib/libPoco*.so.* ${pack}/DSN_ROOT/lib/
copy_file ./thirdparty/output/lib/libtcmalloc_and_profiler.so.4 ${pack}/DSN_ROOT/lib/

if [ "$use_jemalloc" == "on" ]; then
copy_file ./thirdparty/output/lib/libjemalloc.so.2 ${pack}/DSN_ROOT/lib/
copy_file ./thirdparty/output/lib/libprofiler.so.0 ${pack}/DSN_ROOT/lib/
else
copy_file ./thirdparty/output/lib/libtcmalloc_and_profiler.so.4 ${pack}/DSN_ROOT/lib/
fi

copy_file ./thirdparty/output/lib/libboost*.so.1.69.0 ${pack}/DSN_ROOT/lib/
copy_file ./thirdparty/output/lib/libhdfs* ${pack}/DSN_ROOT/lib
copy_file `get_stdcpp_lib $custom_gcc` ${pack}/DSN_ROOT/lib/
Expand Down
8 changes: 8 additions & 0 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ else
echo "DISABLE_GPERF=NO"
fi

if [ "$USE_JEMALLOC" == "ON" ]
then
echo "USE_JEMALLOC=ON"
CMAKE_OPTIONS="$CMAKE_OPTIONS -DUSE_JEMALLOC=ON"
else
echo "USE_JEMALLOC=OFF"
fi

CMAKE_OPTIONS="$CMAKE_OPTIONS -DBoost_NO_BOOST_CMAKE=ON -DBOOST_ROOT=${ROOT}/thirdparty/output -DBoost_NO_SYSTEM_PATHS=ON"

echo "#############################################################################"
Expand Down
4 changes: 2 additions & 2 deletions src/rdsn/scripts/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ fi

if [ "$USE_JEMALLOC" == "ON" ]
then
echo "USE_JEMALLOC=YES"
echo "USE_JEMALLOC=ON"
CMAKE_OPTIONS="$CMAKE_OPTIONS -DUSE_JEMALLOC=ON"
else
echo "USE_JEMALLOC=NO"
echo "USE_JEMALLOC=OFF"
fi

if [ ! -z "$SANITIZER" ]
Expand Down

0 comments on commit 785b3b7

Please sign in to comment.