From 097d5a426a40ed79887f1c7c57db3dc36aa8e1c2 Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Sat, 10 Aug 2019 19:08:35 +0200 Subject: [PATCH] better calculate number of threads to use --- functions.sh | 8 ++++++-- install.sh | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/functions.sh b/functions.sh index 4ea3a54..6e394fd 100755 --- a/functions.sh +++ b/functions.sh @@ -50,9 +50,13 @@ check_cpu () { } calc_threads () { + # Each thread needs 2048 byte (2 Megabyte) + # Calculate number of threads supported with L3 cache size + + _ENV_THREAD_QTY=$(( ($_ENV_CORE_L3/2048)/1000 )) # Affine number of threads for _CPU_CN - _COUNTER="$(( $_ENV_CORE-1 ))" + _COUNTER="$(( $_ENV_THREAD_QTY-1 ))" _ENV_CPU_THREAD_AFFINITY="$(seq -s " " 0 $_COUNTER)" @@ -69,7 +73,7 @@ calc_hugepages () { sudo sysctl -p else # Set value in current env - sudo sysctl -w vm.nr_hugepages="$_ENV_CORE" + sudo sysctl -w vm.nr_hugepages="$_ENV_THREAD_QTY" # Add value to sysctl sudo sysctl -p fi diff --git a/install.sh b/install.sh index 3ad9883..7521097 100755 --- a/install.sh +++ b/install.sh @@ -1,11 +1,11 @@ #!/bin/bash -_DEBUG=true +_DEBUG=$1 if $_DEBUG; then - set -x -else set +x +else + set -x fi # Set that user passwdless sudo