diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2021-07-19 13:03:02 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2021-07-26 10:12:26 +0000 |
commit | 268e16e2ba1eaef8e211d6a0728c92f8cbde14c0 (patch) | |
tree | 0107e824671646d8e1b49629ea6133e906a5b182 /jenkins-helpers.sh | |
parent | 3922f589ab98b50295674d01287ed7fc693bbb47 (diff) |
start-container-docker.sh: Use at most half of RAM on normal builders
This reverts commit 73ab5ac992942292817b1441472d325ed4c553be.
Change-Id: Ia4148af0ac04a5f75b63d5c5af5a334939a39a03
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r-- | jenkins-helpers.sh | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh index 62cc9e0a..7feb3edf 100644 --- a/jenkins-helpers.sh +++ b/jenkins-helpers.sh @@ -694,16 +694,33 @@ print_cpu_shares () # Print memory allocation for $task and $weight. # $1: task # $2: weight +# $3: number of expected parallel processes +# $4: amount of system RAM in MB print_memory_limit () { ( set -euf -o pipefail local task="$1" local weight="$2" + local nproc="$3" + local memlimit="$4" local memory case "$task" in build) - memory="unlimited" + # 2GB per compilation core, with 4GB minimum and + # half of total system RAM maximum. + memory=$(( 2000 * $weight * $nproc )) + + memlimit=$(( $memlimit / 2 )) + if [ "$memlimit" -lt "4000" ]; then + # Don't limit memory on machines with less than 8GB RAM. + memory="unlimited" + else + # Use at most half of RAM + if [ "$memory" -gt "$memlimit" ]; then + memory="$memlimit" + fi + fi ;; test) # 0.75GB per session |