aboutsummaryrefslogtreecommitdiffstats
path: root/vespabase/src/common-env.sh
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@verizonmedia.com>2021-08-19 15:06:28 +0200
committerArnstein Ressem <aressem@verizonmedia.com>2021-08-19 15:06:28 +0200
commitd72a1cdc1dc243bbc5c6088fd6c9b318ab0b7185 (patch)
tree2f1862ecf4fef66106022bac1346738b01f0822a /vespabase/src/common-env.sh
parent6a5eda8ab6642ef223192a863fa5df37ba232ad8 (diff)
Exit with error with no numactl. Use numactl if NUMA nodes are available and we have permissions to use it.
Diffstat (limited to 'vespabase/src/common-env.sh')
-rwxr-xr-xvespabase/src/common-env.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/vespabase/src/common-env.sh b/vespabase/src/common-env.sh
index eb60154071c..d5f8381432f 100755
--- a/vespabase/src/common-env.sh
+++ b/vespabase/src/common-env.sh
@@ -292,3 +292,30 @@ log_debug_message () {
log_warning_message () {
log_message "warning" "$*" 1>&2
}
+
+get_numa_ctl_cmd () {
+ if ! type numactl &> /dev/null; then
+ echo "FATAL: Could not find required program numactl."
+ exit 1
+ fi
+
+ numnodes=$(numactl --hardware 2>/dev/null |
+ grep available |
+ awk '$3 == "nodes" { print $2 }')
+
+ if [ -n "$numanodes" ]; then
+ # We are allowed to use numactl and have NUMA nodes
+ if [ "$VESPA_AFFINITY_CPU_SOCKET" ] &&
+ [ "$numnodes" -gt 1 ]
+ then
+ node=$(($VESPA_AFFINITY_CPU_SOCKET % $numnodes))
+ numactlcmd="numactl --cpunodebind=$node --membind=$node"
+ else
+ numactlcmd="numactl --interleave all"
+ fi
+ else
+ numactlcmd=""
+ fi
+
+ echo $numactlcmd
+}