From c1569b2e0909d6cd38d26515bf94403c8eac1dd1 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Sun, 15 Dec 2024 18:39:46 +0100 Subject: [PATCH] [CI] Allow explicitly override of worker count in run gradle script (#118734) This makes running experiments on ci way easier without changing default behaviour --- .ci/scripts/run-gradle.sh | 56 +++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/.ci/scripts/run-gradle.sh b/.ci/scripts/run-gradle.sh index af5db8a6b4063..b091c4a7c7d89 100755 --- a/.ci/scripts/run-gradle.sh +++ b/.ci/scripts/run-gradle.sh @@ -5,35 +5,39 @@ mkdir -p ~/.gradle/init.d && cp -v $WORKSPACE/.ci/init.gradle ~/.gradle/init.d MAX_WORKERS=4 -# Don't run this stuff on Windows -if ! uname -a | grep -q MING; then - # drop page cache and kernel slab objects on linux - [[ -x /usr/local/sbin/drop-caches ]] && sudo /usr/local/sbin/drop-caches +if [ -z "$MAX_WORKER_ENV" ]; then + # Don't run this stuff on Windows + if ! uname -a | grep -q MING; then + # drop page cache and kernel slab objects on linux + [[ -x /usr/local/sbin/drop-caches ]] && sudo /usr/local/sbin/drop-caches - if [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then - MAX_WORKERS=16 - elif [ -f /proc/cpuinfo ]; then - MAX_WORKERS=`grep '^cpu\scores' /proc/cpuinfo | uniq | sed 's/\s\+//g' | cut -d':' -f 2` - else - if [[ "$OSTYPE" == "darwin"* ]]; then - MAX_WORKERS=`sysctl -n hw.physicalcpu | sed 's/\s\+//g'` - else - echo "Unsupported OS Type: $OSTYPE" - exit 1 - fi - fi - if pwd | grep -v -q ^/dev/shm ; then - echo "Not running on a ramdisk, reducing number of workers" - MAX_WORKERS=$(($MAX_WORKERS*2/3)) - fi + if [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then + MAX_WORKERS=16 + elif [ -f /proc/cpuinfo ]; then + MAX_WORKERS=`grep '^cpu\scores' /proc/cpuinfo | uniq | sed 's/\s\+//g' | cut -d':' -f 2` + else + if [[ "$OSTYPE" == "darwin"* ]]; then + MAX_WORKERS=`sysctl -n hw.physicalcpu | sed 's/\s\+//g'` + else + echo "Unsupported OS Type: $OSTYPE" + exit 1 + fi + fi + if pwd | grep -v -q ^/dev/shm ; then + echo "Not running on a ramdisk, reducing number of workers" + MAX_WORKERS=$(($MAX_WORKERS*2/3)) + fi - # Export glibc version as environment variable since some BWC tests are incompatible with later versions - export GLIBC_VERSION=$(ldd --version | grep '^ldd' | sed 's/.* \([1-9]\.[0-9]*\).*/\1/') -fi + # Export glibc version as environment variable since some BWC tests are incompatible with later versions + export GLIBC_VERSION=$(ldd --version | grep '^ldd' | sed 's/.* \([1-9]\.[0-9]*\).*/\1/') + fi -# Running on 2-core machines without ramdisk can make this value be 0 -if [[ "$MAX_WORKERS" == "0" ]]; then - MAX_WORKERS=1 + # Running on 2-core machines without ramdisk can make this value be 0 + if [[ "$MAX_WORKERS" == "0" ]]; then + MAX_WORKERS=1 + fi +else + MAX_WORKERS=$MAX_WORKER_ENV fi set -e