aboutsummaryrefslogtreecommitdiffstats
path: root/vespabase/src/common-env.sh
diff options
context:
space:
mode:
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
+}