summaryrefslogtreecommitdiffstats
path: root/container-disc
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@yahoo-inc.com>2016-10-05 11:58:26 +0200
committerHåkon Hallingstad <hakon@yahoo-inc.com>2016-10-05 11:58:26 +0200
commit32ee9602e33b8883c4d66845a37f01813d2915e4 (patch)
treea4a5a94c1373f999343e7742c1b210433827e3d4 /container-disc
parent98ec1ff03137e089734ce0a90df38e234be9409d (diff)
Only update jvm_heapsize if percentage has been set
Diffstat (limited to 'container-disc')
-rwxr-xr-xcontainer-disc/src/main/sh/vespa-start-container-daemon.sh30
1 files changed, 14 insertions, 16 deletions
diff --git a/container-disc/src/main/sh/vespa-start-container-daemon.sh b/container-disc/src/main/sh/vespa-start-container-daemon.sh
index 77027e2a938..ec632a9c0c4 100755
--- a/container-disc/src/main/sh/vespa-start-container-daemon.sh
+++ b/container-disc/src/main/sh/vespa-start-container-daemon.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#set -x
@@ -60,28 +60,26 @@ getconfig() {
}
configure_memory() {
+ consider_fallback jvm_heapsize 1536
consider_fallback jvm_stacksize 512
consider_fallback jvm_baseMaxDirectMemorySize 75
consider_fallback jvm_directMemorySizeCache 0
- if ! varhasvalue jvm_heapsize; then
- if varhasvalue jvm_heapSizeAsPercentageOfPhysicalMemory; then
- if varhasvalue TOTAL_MEMORY_MB; then
- available="$TOTAL_MEMORY_MB"
- else
- available=`free -m | grep Mem | tr -s ' ' | cut -f2 -d' '`
- fi
-
- jvm_heapsize=$[available * jvm_heapSizeAsPercentageOfPhysicalMemory / 100]
- if (( jvm_heapsize < 1024 )); then
- jvm_heapsize=1024
- fi
+ # Update jvm_heapsize only if percentage is explicitly set (default is 0).
+ if ((jvm_heapSizeAsPercentageOfPhysicalMemory > 0)); then
+ if ((TOTAL_MEMORY_MB > 0)); then
+ available="$TOTAL_MEMORY_MB"
else
- jvm_heapsize=1536
- fi
+ available=`free -m | grep Mem | tr -s ' ' | cut -f2 -d' '`
+ fi
+
+ jvm_heapsize=$((available * jvm_heapSizeAsPercentageOfPhysicalMemory / 100))
+ if (( jvm_heapsize < 1024 )); then
+ jvm_heapsize=1024
+ fi
fi
- maxDirectMemorySize=$(( ${jvm_baseMaxDirectMemorySize} + ${jvm_heapsize}/8 + ${jvm_directMemorySizeCache} ))
+ maxDirectMemorySize=$(( jvm_baseMaxDirectMemorySize + jvm_heapsize / 8 + jvm_directMemorySizeCache ))
memory_options="-Xms${jvm_heapsize}m -Xmx${jvm_heapsize}m"
memory_options="${memory_options} -XX:ThreadStackSize=${jvm_stacksize}"