Feature/sangshuduo/td 3973 use jemalloc (#6319)
* [TD-3973]<feature>: add jemalloc as submodule. * add macro definitions in cmake. * [TD-3973]<feature>: use jemalloc. build works as following instructions: cmake .. -DJEMALLOC_ENABLED=true make * fix jemalloc at tag 5.2.1 * link jemalloc works. * make install works. * support jemalloc in release.sh. Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
parent
ca3ec15956
commit
09c4c28169
|
@ -10,3 +10,6 @@
|
|||
[submodule "tests/examples/rust"]
|
||||
path = tests/examples/rust
|
||||
url = https://github.com/songtianyi/tdengine-rust-bindings.git
|
||||
[submodule "deps/jemalloc"]
|
||||
path = deps/jemalloc
|
||||
url = https://github.com/jemalloc/jemalloc
|
||||
|
|
|
@ -59,6 +59,11 @@ IF (TD_LINUX_64)
|
|||
MESSAGE(STATUS "linux64 is defined")
|
||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||
|
||||
IF (JEMALLOC_ENABLED)
|
||||
ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
|
||||
ENDIF ()
|
||||
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_LINUX_32)
|
||||
|
|
|
@ -72,3 +72,8 @@ IF (${RANDOM_NETWORK_FAIL} MATCHES "true")
|
|||
SET(TD_RANDOM_NETWORK_FAIL TRUE)
|
||||
MESSAGE(STATUS "build with random-network-fail enabled")
|
||||
ENDIF ()
|
||||
|
||||
IF (${JEMALLOC_ENABLED} MATCHES "true")
|
||||
SET(TD_JEMALLOC_ENABLED TRUE)
|
||||
MESSAGE(STATUS "build with jemalloc enabled")
|
||||
ENDIF ()
|
||||
|
|
|
@ -18,3 +18,16 @@ ENDIF ()
|
|||
IF (TD_DARWIN AND TD_MQTT)
|
||||
ADD_SUBDIRECTORY(MQTT-C)
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||
MESSAGE("setup dpes/jemalloc, current source dir:" ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
MESSAGE("binary dir:" ${CMAKE_BINARY_DIR})
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(jemalloc
|
||||
PREFIX "jemalloc"
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/
|
||||
BUILD_COMMAND ${MAKE}
|
||||
)
|
||||
ENDIF ()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit ea6b3e973b477b8061e0076bb257dbd7f3faa756
|
|
@ -22,11 +22,12 @@ cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 ...]
|
|||
osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
|
||||
pagMode=full # [full | lite]
|
||||
soMode=dynamic # [static | dynamic]
|
||||
allocator=glibc # [glibc | jemalloc]
|
||||
dbName=taos # [taos | power]
|
||||
verNumber=""
|
||||
verNumberComp="2.0.0.0"
|
||||
|
||||
while getopts "hv:V:c:o:l:s:d:n:m:" arg
|
||||
while getopts "hv:V:c:o:l:s:d:a:n:m:" arg
|
||||
do
|
||||
case $arg in
|
||||
v)
|
||||
|
@ -53,6 +54,10 @@ do
|
|||
#echo "dbName=$OPTARG"
|
||||
dbName=$(echo $OPTARG)
|
||||
;;
|
||||
a)
|
||||
#echo "allocator=$OPTARG"
|
||||
allocator=$(echo $OPTARG)
|
||||
;;
|
||||
n)
|
||||
#echo "verNumber=$OPTARG"
|
||||
verNumber=$(echo $OPTARG)
|
||||
|
@ -71,6 +76,7 @@ do
|
|||
echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
|
||||
echo " -V [stable | beta] "
|
||||
echo " -l [full | lite] "
|
||||
echo " -a [glibc | jemalloc] "
|
||||
echo " -s [static | dynamic] "
|
||||
echo " -d [taos | power] "
|
||||
echo " -n [version number] "
|
||||
|
@ -84,7 +90,7 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} dbName=${dbName} verNumber=${verNumber} verNumberComp=${verNumberComp}"
|
||||
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} dbName=${dbName} allocator=${allocator} verNumber=${verNumber} verNumberComp=${verNumberComp}"
|
||||
|
||||
curr_dir=$(pwd)
|
||||
|
||||
|
@ -180,12 +186,18 @@ else
|
|||
fi
|
||||
cd ${compile_dir}
|
||||
|
||||
if [[ "$allocator" == "jemalloc" ]]; then
|
||||
allocator_macro="-DJEMALLOC_ENABLED=true"
|
||||
else
|
||||
allocator_macro=""
|
||||
fi
|
||||
|
||||
# check support cpu type
|
||||
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then
|
||||
if [ "$verMode" != "cluster" ]; then
|
||||
cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode}
|
||||
cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} ${allocator_macro}
|
||||
else
|
||||
cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp}
|
||||
cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} ${allocator_macro}
|
||||
fi
|
||||
else
|
||||
echo "input cpuType=${cpuType} error!!!"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
set -e
|
||||
# set -x
|
||||
|
||||
# -----------------------Variables definition---------------------
|
||||
# -----------------------Variables definition
|
||||
source_dir=$1
|
||||
binary_dir=$2
|
||||
osType=$3
|
||||
|
@ -176,6 +176,49 @@ function install_bin() {
|
|||
[ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || :
|
||||
fi
|
||||
}
|
||||
function install_jemalloc() {
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
/usr/bin/install -c -d /usr/local/bin
|
||||
|
||||
if [ -f ${binary_dir}/build/bin/jemalloc-config ]; then
|
||||
/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc-config /usr/local/bin
|
||||
fi
|
||||
if [ -f ${binary_dir}/build/bin/jemalloc.sh ]; then
|
||||
/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc.sh /usr/local/bin
|
||||
fi
|
||||
if [ -f ${binary_dir}/build/bin/jeprof ]; then
|
||||
/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jeprof /usr/local/bin
|
||||
fi
|
||||
if [ -f ${binary_dir}/build/include/jemalloc/jemalloc.h ]; then
|
||||
/usr/bin/install -c -d /usr/local/include/jemalloc
|
||||
/usr/bin/install -c -m 644 ${binary_dir}/build/include/jemalloc/jemalloc.h /usr/local/include/jemalloc
|
||||
fi
|
||||
if [ -f ${binary_dir}/build/lib/libjemalloc.so.2 ]; then
|
||||
/usr/bin/install -c -d /usr/local/lib
|
||||
/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.so.2 /usr/local/lib
|
||||
ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so
|
||||
/usr/bin/install -c -d /usr/local/lib
|
||||
if [ -f ${binary_dir}/build/lib/libjemalloc.a ]; then
|
||||
/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.a /usr/local/lib
|
||||
fi
|
||||
if [ -f ${binary_dir}/build/lib/libjemalloc_pic.a ]; then
|
||||
/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc_pic.a /usr/local/lib
|
||||
fi
|
||||
if [ -f ${binary_dir}/build/lib/libjemalloc_pic.a ]; then
|
||||
/usr/bin/install -c -d /usr/local/lib/pkgconfig
|
||||
/usr/bin/install -c -m 644 ${binary_dir}/build/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig
|
||||
fi
|
||||
fi
|
||||
if [ -f ${binary_dir}/build/share/doc/jemalloc/jemalloc.html ]; then
|
||||
/usr/bin/install -c -d /usr/local/share/doc/jemalloc
|
||||
/usr/bin/install -c -m 644 ${binary_dir}/build/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc
|
||||
fi
|
||||
if [ -f ${binary_dir}/build/share/man/man3/jemalloc.3 ]; then
|
||||
/usr/bin/install -c -d /usr/local/share/man/man3
|
||||
/usr/bin/install -c -m 644 ${binary_dir}/build/share/man/man3/jemalloc.3 /usr/local/share/man/man3
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function install_lib() {
|
||||
# Remove links
|
||||
|
@ -199,6 +242,8 @@ function install_lib() {
|
|||
${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib
|
||||
fi
|
||||
|
||||
install_jemalloc
|
||||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
${csudo} ldconfig
|
||||
fi
|
||||
|
@ -431,13 +476,13 @@ function install_TDengine() {
|
|||
# Start to install
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
echo -e "${GREEN}Start to install TDEngine...${NC}"
|
||||
else
|
||||
echo -e "${GREEN}Start to install TDEngine Client ...${NC}"
|
||||
else
|
||||
echo -e "${GREEN}Start to install TDEngine Client ...${NC}"
|
||||
fi
|
||||
|
||||
install_main_path
|
||||
install_main_path
|
||||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
install_data
|
||||
fi
|
||||
install_log
|
||||
|
|
|
@ -10,8 +10,15 @@ INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc)
|
|||
INCLUDE_DIRECTORIES(inc)
|
||||
AUX_SOURCE_DIRECTORY(src SRC)
|
||||
|
||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||
ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
|
||||
SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
|
||||
ELSE ()
|
||||
SET(LINK_JEMALLOC "")
|
||||
ENDIF ()
|
||||
|
||||
ADD_EXECUTABLE(taosd ${SRC})
|
||||
TARGET_LINK_LIBRARIES(taosd mnode monitor http tsdb twal vnode cJson lz4 balance sync)
|
||||
TARGET_LINK_LIBRARIES(taosd mnode monitor http tsdb twal vnode cJson lz4 balance sync ${LINK_JEMALLOC})
|
||||
|
||||
IF (TD_SOMODE_STATIC)
|
||||
TARGET_LINK_LIBRARIES(taosd taos_static)
|
||||
|
|
|
@ -11,10 +11,17 @@ IF (TD_LINUX)
|
|||
LIST(REMOVE_ITEM SRC ./src/shellDarwin.c)
|
||||
ADD_EXECUTABLE(shell ${SRC})
|
||||
|
||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||
ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
|
||||
SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
|
||||
ELSE ()
|
||||
SET(LINK_JEMALLOC "")
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_SOMODE_STATIC)
|
||||
TARGET_LINK_LIBRARIES(shell taos_static)
|
||||
TARGET_LINK_LIBRARIES(shell taos_static ${LINK_JEMALLOC})
|
||||
ELSE ()
|
||||
TARGET_LINK_LIBRARIES(shell taos)
|
||||
TARGET_LINK_LIBRARIES(shell taos ${LINK_JEMALLOC})
|
||||
ENDIF ()
|
||||
|
||||
SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)
|
||||
|
|
|
@ -55,14 +55,21 @@ ENDIF ()
|
|||
MESSAGE("TD_VERSION_NUMBER is:" ${TD_VERSION_NUMBER})
|
||||
ADD_DEFINITIONS(-DTD_VERNUMBER="${TD_VERSION_NUMBER}")
|
||||
|
||||
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||
ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
|
||||
SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
|
||||
ELSE ()
|
||||
SET(LINK_JEMALLOC "")
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_LINUX)
|
||||
AUX_SOURCE_DIRECTORY(. SRC)
|
||||
ADD_EXECUTABLE(taosdemo ${SRC})
|
||||
|
||||
IF (TD_SOMODE_STATIC)
|
||||
TARGET_LINK_LIBRARIES(taosdemo taos_static cJson)
|
||||
TARGET_LINK_LIBRARIES(taosdemo taos_static cJson ${LINK_JEMALLOC})
|
||||
ELSE ()
|
||||
TARGET_LINK_LIBRARIES(taosdemo taos cJson)
|
||||
TARGET_LINK_LIBRARIES(taosdemo taos cJson ${LINK_JEMALLOC})
|
||||
ENDIF ()
|
||||
ELSEIF (TD_WINDOWS)
|
||||
AUX_SOURCE_DIRECTORY(. SRC)
|
||||
|
@ -71,7 +78,7 @@ ELSEIF (TD_WINDOWS)
|
|||
IF (TD_SOMODE_STATIC)
|
||||
TARGET_LINK_LIBRARIES(taosdemo taos_static cJson)
|
||||
ELSE ()
|
||||
TARGET_LINK_LIBRARIES(taosdemo taos cJson})
|
||||
TARGET_LINK_LIBRARIES(taosdemo taos cJson)
|
||||
ENDIF ()
|
||||
ELSEIF (TD_DARWIN)
|
||||
# missing a few dependencies, such as <argp.h>
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef TD_JEMALLOC_ENABLED
|
||||
#include <jemalloc/jemalloc.h>
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
TAOS_ALLOC_MODE_DEFAULT = 0,
|
||||
TAOS_ALLOC_MODE_RANDOM_FAIL = 1,
|
||||
|
|
Loading…
Reference in New Issue