From 8bbe458e48c2c5651748d09c114fbbb664c0cf7e Mon Sep 17 00:00:00 2001 From: Shijith Thotton Date: Thu, 13 Jun 2019 14:20:30 +0800 Subject: [PATCH] disable heap trimming while running gzip benchmark gzip dynamic memory allocation size per compression is 136K. It is above malloc trim threshold of 128K. So heap will be trimmed on each loop as we call free. It causes break system call to be called per loop and impacts performance. Resulting benchmark data will be inaccurate. Trimming can be disabled by setting MALLOC_TRIM_THRESHOLD_ to -1. New allocations will also cause an increase in page faults. Below are the results for gzip with quality 4 and single thread: Page faults with trimming: 392,546 Page faults without trimming: 388 Signed-off-by: Shijith Thotton --- run_benchmarks.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/run_benchmarks.sh b/run_benchmarks.sh index 64dc1ce..c2b2207 100755 --- a/run_benchmarks.sh +++ b/run_benchmarks.sh @@ -10,6 +10,10 @@ echo $out nprocs=`cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l` +if [ ! -z "$MALLOC_TRIM_THRESHOLD_" ]; then + old_trim_threshold=$MALLOC_TRIM_THRESHOLD_ +fi + sudo apt-get install -y build-essential bc golang export GOPATH="$(dirname "$(readlink -f "$0")")" @@ -38,6 +42,17 @@ if [ ! -f ./bench ]; then fi cd .. +disable_malloc_trim_threshold () { + export MALLOC_TRIM_THRESHOLD_=-1 +} + +restore_malloc_trim_threshold () { + if [ ! -z "$old_trim_threshold" ]; then + export MALLOC_TRIM_THRESHOLD_=$old_trim_threshold + else + unset MALLOC_TRIM_THRESHOLD_ + fi +} openssl_aead () { res=`./openssl/apps/openssl speed -seconds 10 -bytes 16384 -multi $2 -evp $1 | tail -1 | rev | cut -f 1 -d ' ' | rev | sed 's/k//' ` @@ -93,9 +108,11 @@ for q in {4..11}; do done echo "gzip performance (cloudflare zlib)" | tee -a $out +disable_malloc_trim_threshold for q in {4..9}; do echo gzip -$q,$( comp $q 1 ),$( comp $q $nprocs ) | tee -a $out done +restore_malloc_trim_threshold echo "Go performance" | tee -a $out go run ./go_benchmarks.go | tee -a $out