aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-06-16 08:27:22 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-06-16 08:27:22 +0000
commitff9785791affddb70748738bc38eb6a0610be9a2 (patch)
tree188e68046b40a6f40e7978fb44ca2d22a7d23faa
parent28b57f1d58d2af4580cd41a9d2e08b5af63590b8 (diff)
Also consider heap overrides when controlling THP for jvms.
-rwxr-xr-xconfig-proxy/src/main/sh/vespa-config-ctl.sh7
-rwxr-xr-xconfigserver/src/main/sh/start-configserver7
-rwxr-xr-xstandalone-container/src/main/sh/standalone-container.sh7
-rwxr-xr-xvespabase/src/common-env.sh31
4 files changed, 37 insertions, 15 deletions
diff --git a/config-proxy/src/main/sh/vespa-config-ctl.sh b/config-proxy/src/main/sh/vespa-config-ctl.sh
index aa36e09c995..d6d0075b555 100755
--- a/config-proxy/src/main/sh/vespa-config-ctl.sh
+++ b/config-proxy/src/main/sh/vespa-config-ctl.sh
@@ -109,11 +109,8 @@ case $1 in
nohup nice sbin/vespa-retention-enforcer > ${LOGDIR}/vre-start.log 2>&1 </dev/null &
configsources=`bin/vespa-print-default configservers_rpc`
userargs=$VESPA_CONFIGPROXY_JVMARGS
- # Note that the hardcoded memory Xmx=128 migh be overriden in VESPA_CONFIGPROXY_JVMARGS,
- # hence rendering get_jvm_hugepage_settings incorrect, but it is better than not.
- # TODO Better way of extracting heap size arguments.
- heap_min=32
- heap_max=128
+ heap_min=$(get_min_heap_mb "${userargs}" 32)
+ heap_max=$(get_max_heap_mb "${userargs}" 128)
jvmopts="-Xms${heap_min}M -Xmx${heap_max}M -XX:+PreserveFramePointer $(get_jvm_hugepage_settings $heap_max) -XX:CompressedClassSpaceSize=32m -XX:MaxDirectMemorySize=32m -XX:ThreadStackSize=448 -XX:MaxJavaStackTraceDepth=1000 -XX:-OmitStackTraceInFastThrow"
VESPA_SERVICE_NAME=configproxy
diff --git a/configserver/src/main/sh/start-configserver b/configserver/src/main/sh/start-configserver
index cf0ebfbbe40..8127b0bfafc 100755
--- a/configserver/src/main/sh/start-configserver
+++ b/configserver/src/main/sh/start-configserver
@@ -161,11 +161,8 @@ rm -f $cfpfile
vespa-run-as-vespa-user sh -c "printenv > $cfpfile"
fixddir $bundlecachedir
-# Note that the hardcoded memory Xmx=2048 migh be overridden by jvmargs,
-# hence rendering get_jvm_hugepage_settings incorrect, but it is better than not.
-# TODO Better way of extracting heap size arguments.
-heap_min=128
-heap_max=2048
+heap_min=$(get_min_heap_mb "${jvmargs}" 128)
+heap_max=$(get_max_heap_mb "${jvmargs}" 2048)
vespa-run-as-vespa-user vespa-runserver -s ${VESPA_SERVICE_NAME} -r 30 -p $pidfile -- \
java \
-Xms${heap_min}m -Xmx${heap_max}m \
diff --git a/standalone-container/src/main/sh/standalone-container.sh b/standalone-container/src/main/sh/standalone-container.sh
index cb5d7e3d060..f55a6df5b76 100755
--- a/standalone-container/src/main/sh/standalone-container.sh
+++ b/standalone-container/src/main/sh/standalone-container.sh
@@ -167,11 +167,8 @@ StartCommand() {
FixDataDirectory "$bundlecachedir"
FixDataDirectory "$VESPA_HOME/var/crash"
- # Note that the hardcoded memory Xmx=2048 migh be overridden by jvm_arguments,
- # hence rendering get_jvm_hugepage_settings incorrect, but it is better than not.
- # TODO Better way of extracting heap size arguments.
- heap_min=128
- heap_max=2048
+ heap_min=$(get_min_heap_mb "${jvm_arguments}" 128)
+ heap_max=$(get_max_heap_mb "${jvm_arguments}" 2048)
java \
-Xms${heap_min}m -Xmx${heap_max}m \
-XX:+PreserveFramePointer \
diff --git a/vespabase/src/common-env.sh b/vespabase/src/common-env.sh
index 7b812d40fec..b64de704d85 100755
--- a/vespabase/src/common-env.sh
+++ b/vespabase/src/common-env.sh
@@ -158,6 +158,37 @@ get_jvm_hugepage_settings() {
echo "$options"
}
+get_heap_size() {
+ param=$1
+ args=$2
+ value=$3
+ for token in $args
+ do
+ [[ "$token" =~ ^"${param}"([0-9]+)(.)$ ]] || continue
+ size="${BASH_REMATCH[1]}"
+ unit="${BASH_REMATCH[2],,}" # lower-case
+ case "$unit" in
+ k) value=$(( $size / 1024 )) ;;
+ m) value="$size" ;;
+ g) value=$(( $size * 1024 )) ;;
+ *) echo "Warning: Invalid unit in '$token'" >&2 ;;
+ esac
+ done
+ echo "$value"
+}
+
+get_min_heap_mb() {
+ args=$1
+ size=$2
+ get_heap_size "-Xms" "$args" $size
+}
+
+get_max_heap_mb() {
+ args=$1
+ size=$2
+ get_heap_size "-Xmx" "$args" $size
+}
+
populate_environment
export LD_LIBRARY_PATH=$VESPA_HOME/lib64