hypersolana/ci/common/limit-threads.sh
Yihau Chen 8a849718d2
ci: cleanup (#31196)
* extract threads limit script

* extract common functions

* mv need_to_generate_test_result need_to_upload_test_result
2023-04-14 20:37:07 +00:00

17 lines
340 B
Bash
Executable File

#!/usr/bin/env bash
set -e
# limit jobs to 4gb/thread
if [[ -f "/proc/meminfo" ]]; then
JOBS=$(grep MemTotal /proc/meminfo | awk '{printf "%.0f", ($2 / (4 * 1024 * 1024))}')
else
JOBS=$(sysctl hw.memsize | awk '{printf "%.0f", ($2 / (4 * 1024**3))}')
fi
NPROC=$(nproc)
JOBS=$((JOBS > NPROC ? NPROC : JOBS))
export NPROC
export JOBS