From 1ac7f28c15e64c82e7db29988dea15a6a2eb57ce Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Thu, 1 Aug 2019 20:29:24 +0200 Subject: [PATCH 1/3] Add notice --- settings.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/settings.sh b/settings.sh index b0a293a..ea7fddd 100755 --- a/settings.sh +++ b/settings.sh @@ -11,7 +11,11 @@ _RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwj _POOL_SERVER_URL="192.168.4.5" _POOL_SERVER_PORT="3333" -################################# +##################################################################### + +# DO NOT CHANGE AFTER THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING + +##################################################################### # Set working directory _WORK_DIR="$(pwd)" From 86bb3cbda5b9f570f93efc52653fcc8746b56acc Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Thu, 1 Aug 2019 20:29:24 +0200 Subject: [PATCH 2/3] Revert "Add notice" This reverts commit 1ac7f28c15e64c82e7db29988dea15a6a2eb57ce. --- settings.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/settings.sh b/settings.sh index ea7fddd..b0a293a 100755 --- a/settings.sh +++ b/settings.sh @@ -11,11 +11,7 @@ _RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwj _POOL_SERVER_URL="192.168.4.5" _POOL_SERVER_PORT="3333" -##################################################################### - -# DO NOT CHANGE AFTER THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING - -##################################################################### +################################# # Set working directory _WORK_DIR="$(pwd)" From 2c0973365ce06acc209cad56659c465660c66d6b Mon Sep 17 00:00:00 2001 From: Sean Wheller Date: Thu, 1 Aug 2019 22:22:11 +0200 Subject: [PATCH 3/3] handle cpu affinity --- config.sh | 2 +- settings.sh | 53 +++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/config.sh b/config.sh index 2ed685e..3df1421 100755 --- a/config.sh +++ b/config.sh @@ -14,7 +14,7 @@ _CPU_HUGE_PAGES="true" _CPU_HW_AES="$_AES_NI" _CPU_PRIORITY="null" _CPU_ASM="true" -_CPU_CN="0 1 2 3" +_CPU_CN="$_ENV_CPU_THREAD_AFFINITY" _CPU_CN_0="false" _CPU_CN_LITE_0="false" diff --git a/settings.sh b/settings.sh index b0a293a..a1ba074 100755 --- a/settings.sh +++ b/settings.sh @@ -11,7 +11,11 @@ _RECEIVE_WALLET="854sqm2Cm4TB2XgPHWqSPSbnFAe3SMzdEDzZHpukQ8NHBPFropbnkFmEKiZPgwj _POOL_SERVER_URL="192.168.4.5" _POOL_SERVER_PORT="3333" -################################# +##################################################################### + +# DO NOT CHANGE AFTER THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING + +##################################################################### # Set working directory _WORK_DIR="$(pwd)" @@ -76,10 +80,48 @@ else echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/README fi + +# Check if CPU supports AES-NI +cpuid | grep -i aes > hw-aes.txt +if grep -q true "hw-aes.txt"; then + _AES_NI=true +else + _AES_NI=false +fi +rm hw-aes.txt + # Get number of available CPU Cores _ENV_CORE=$(nproc --all) echo -e "CPU Cores: $_ENV_CORE\n" +# Get CPU L3 cache value +_ENV_CORE_L3=$(getconf LEVEL3_CACHE_SIZE) +echo -e "L3 Cache in byte: $_ENV_CORE_L3\n" + +# Determine number of threads possible +_ENV_CORE_L3_MB="$(($_ENV_CORE_L3 / 1000000))" +echo -e "L3 cache in Megabyte: $_ENV_CORE_L3_MB\n" + +# Determine number of threads possible +_ENV_CORE_THREADS="$(($_ENV_CORE_L3_MB / 2))" +echo "Each thread requires 2 MB of cache" +echo -e "Number of threads possible is: $_ENV_CORE_THREADS\n" + +# Affine number of threads for _CPU_CN +_COUNTER="$(($_ENV_CORE_THREADS - 1))" +_ENV_CPU_THREADS=() + +for i in `seq 0 $_COUNTER`; do + _ENV_CPU_THREADS+=("$i") +done + +echo "Thread CPU Affinity: ${_ENV_CPU_THREADS[@]}" + +_ENV_CPU_THREAD_AFFINITY="${_ENV_CPU_THREADS[@]}" + + +# Setting according to cpu cores but xmrig will not use all +# change to make value use _ENV_CORE_THREADS # Check that hugepages set in /etc/sysctl.conf _ENV_CHECK="nr_hugepages" @@ -97,15 +139,6 @@ else echo "vm.nr_hugepages=$_ENV_CORE" | sudo tee -a /etc/sysctl.conf fi -# Check if CPU supports AES-NI -cpuid | grep -i aes > hw-aes.txt -if grep -q true "hw-aes.txt"; then - _AES_NI=true -else - _AES_NI=false -fi -rm hw-aes.txt - # Run apt maintenance # 1 = yes 0 = no _APT_MAINETANCE="1"