Skip to content

Commit da78658

Browse files
committed
HPCC-35485 Add jemalloc allocator config option for LD_PRELOAD
Signed-off-by: M Kelly <mark.kelly@lexisnexisrisk.com>
1 parent d56c768 commit da78658

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,14 @@ if(PLATFORM OR CLIENTTOOLS OR REMBED)
552552
install(FILES ${HPCC_SOURCE_DIR}/${LICENSE_FILE} DESTINATION "." COMPONENT Runtime)
553553
endif()
554554

555+
# Install jemalloc library from vcpkg
556+
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND PLATFORM)
557+
file(GLOB JEMALLOC_LIBS "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libjemalloc.*")
558+
if (JEMALLOC_LIBS)
559+
install(FILES ${JEMALLOC_LIBS} DESTINATION "lib")
560+
endif()
561+
endif()
562+
555563
add_subdirectory(devel)
556564

557565
#uninstall target

initfiles/etc/DIR_NAME/environment.conf.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ mpStart=7101
3030
mpEnd=7500
3131
mpSoMaxConn=128
3232
mpTraceLevel=0
33+
34+
useJemalloc=true
35+
3336
# enable SSL for dafilesrv remote file access (SSLNone/false | SSLOnly/true | SSLFirst | UnsecureFirst | UnsecureAndSSL)
3437
# Enabling requires setting the HPCCPassPhrase, HPCCCertFile, and HPCCPrivateKeyFile values
3538
#dfsUseSSL=SSLNone

initfiles/sbin/hpcc_setenv.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ if [ -z "$MALLOC_ARENA_MAX" ]; then
130130
export MALLOC_ARENA_MAX=$num_arenas
131131
fi
132132

133+
# search env or conf file for useJemalloc=true/false setting and if true, add libjemalloc to LD_PRELOAD
134+
HPCC_XMLFILE=${HPCC_XMLFILE:-${CONFIG_DIR}/${ENV_XML_FILE}}
135+
136+
usejem=$(sed -n '/\<envsettings/I,/\/envsettings/I{//!p;}' ${HPCC_XMLFILE} 2>/dev/null | awk -F '[<>]' 'tolower($0)~/usejemalloc/{print $3}' 2>/dev/null)
137+
if [[ "$usejem" == "" ]] ; then
138+
usejem=$(grep -i usejemalloc ${HPCC_CONFIG} 2> /dev/null | awk -F= '{print $2}' 2>/dev/null)
139+
if [[ "$usejem" == "" ]] ; then
140+
usejem="false"
141+
fi
142+
fi
143+
144+
if [[ "$usejem" == "true" ]] ; then
145+
if [[ -s ${INSTALL_DIR}/lib/libjemalloc.so ]] ; then
146+
if [[ ! "$LD_PRELOAD" =~ .*libjemalloc.* ]] ; then
147+
LD_PRELOAD=${INSTALL_DIR}/lib/libjemalloc.so:${LD_PRELOAD}
148+
fi
149+
fi
150+
fi
151+
133152
PATH_PREFIX=`cat ${HPCC_CONFIG} | sed -n "/\[${SECTION}\]/,/\[/p" | grep "^path *= *" | sed -e 's/^path *= *//'`
134153

135154
export PID=`cat ${HPCC_CONFIG} | sed -n "/\[${SECTION}\]/,/\[/p" | grep "^pid *= *" | sed -e 's/^pid *= *//'`

vcpkg.json.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@
104104
"name": "libiconv",
105105
"platform": "osx"
106106
},
107+
{
108+
"name": "jemalloc",
109+
"platform": "linux"
110+
},
107111
{
108112
"name": "libmemcached",
109113
"platform": "@VCPKG_MEMCACHED@ & !windows & !osx"

0 commit comments

Comments
 (0)