[improvement](memory) set TCMALLOC_HEAP_LIMIT_MB to control memory consumption of tcmalloc (#12981)
This commit is contained in:
@ -204,6 +204,39 @@ fi
|
||||
export ASAN_OPTIONS=symbolize=1:abort_on_error=1:disable_coredump=0:unmap_shadow_on_exit=1
|
||||
export UBSAN_OPTIONS=print_stacktrace=1
|
||||
|
||||
## set TCMALLOC_HEAP_LIMIT_MB to limit memory used by tcmalloc
|
||||
set_tcmalloc_heap_limit() {
|
||||
total_mem_mb=$(free -m | grep Mem | awk '{print $2}')
|
||||
mem_limit_str=$(grep ^mem_limit "${DORIS_HOME}"/conf/be.conf)
|
||||
digits_unit=${mem_limit_str##*=}
|
||||
digits_unit="${digits_unit#"${digits_unit%%[![:space:]]*}"}"
|
||||
digits_unit="${digits_unit%"${digits_unit##*[![:space:]]}"}"
|
||||
digits=${digits_unit%%[^[:digit:]]*}
|
||||
unit=${digits_unit##*[[:digit:] ]}
|
||||
|
||||
mem_limit_mb=0
|
||||
case ${unit} in
|
||||
t | T) mem_limit_mb=$((digits * 1024 * 1024)) ;;
|
||||
g | G) mem_limit_mb=$((digits * 1024)) ;;
|
||||
m | M) mem_limit_mb=$((digits)) ;;
|
||||
k | K) mem_limit_mb=$((digits / 1024)) ;;
|
||||
%) mem_limit_mb=$((total_mem_mb * digits / 100)) ;;
|
||||
*) mem_limit_mb=$((digits / 1024 / 1024 / 1024)) ;;
|
||||
esac
|
||||
|
||||
if [[ "${mem_limit_mb}" -eq 0 ]]; then
|
||||
mem_limit_mb=$((total_mem_mb * 80 / 100))
|
||||
fi
|
||||
|
||||
if [[ "${mem_limit_mb}" -gt "${total_mem_mb}" ]]; then
|
||||
echo "mem_limit is larger than whole memory of the server. ${mem_limit_mb} > ${total_mem_mb}."
|
||||
return 1
|
||||
fi
|
||||
export TCMALLOC_HEAP_LIMIT_MB=${mem_limit_mb}
|
||||
}
|
||||
|
||||
set_tcmalloc_heap_limit || exit 1
|
||||
|
||||
## set hdfs conf
|
||||
export LIBHDFS3_CONF="${DORIS_HOME}/conf/hdfs-site.xml"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user