Limit compiler jobs if the machine has lower than 4gb/thread (#22704)

This commit is contained in:
sakridge
2022-01-28 23:46:46 +01:00
committed by GitHub
parent 40a49081b9
commit 1b7bc8b284
2 changed files with 12 additions and 6 deletions

View File

@ -68,8 +68,13 @@ if [[ -n $CI || -z $1 ]]; then
$(git grep -l "proc-macro.*true" :**/Cargo.toml | sed 's|Cargo.toml|src/lib.rs|')
fi
RUST_LOG=solana=trace _ "$cargo" nightly test --target-dir target/cov --no-run "${packages[@]}"
if RUST_LOG=solana=trace _ "$cargo" nightly test --target-dir target/cov "${packages[@]}" 2> target/cov/coverage-stderr.log; then
# limit jobs to 4gb/thread
JOBS=$(grep MemTotal /proc/meminfo | awk '{printf "%.0f", ($2 / (4 * 1024 * 1024))}')
NPROC=$(nproc)
JOBS=$((JOBS>NPROC ? NPROC : JOBS))
RUST_LOG=solana=trace _ "$cargo" nightly test --jobs "$JOBS" --target-dir target/cov --no-run "${packages[@]}"
if RUST_LOG=solana=trace _ "$cargo" nightly test --jobs "$JOBS" --target-dir target/cov "${packages[@]}" 2> target/cov/coverage-stderr.log; then
test_status=0
else
test_status=$?