From 1b7bc8b284ba18a6c6603efcb9e905914f8a38dc Mon Sep 17 00:00:00 2001 From: sakridge Date: Fri, 28 Jan 2022 23:46:46 +0100 Subject: [PATCH] Limit compiler jobs if the machine has lower than 4gb/thread (#22704) --- ci/test-stable.sh | 9 +++++---- scripts/coverage.sh | 9 +++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ci/test-stable.sh b/ci/test-stable.sh index 0f6bae20e4..25e98116d1 100755 --- a/ci/test-stable.sh +++ b/ci/test-stable.sh @@ -21,15 +21,16 @@ export RUST_BACKTRACE=1 export RUSTFLAGS="-D warnings" source scripts/ulimit-n.sh -# Limit compiler jobs to reduce memory usage -# on machines with 2gb/thread of memory +# limit jobs to 4gb/thread +JOBS=$(grep MemTotal /proc/meminfo | awk '{printf "%.0f", ($2 / (4 * 1024 * 1024))}') NPROC=$(nproc) -NPROC=$((NPROC>14 ? 14 : NPROC)) +JOBS=$((JOBS>NPROC ? NPROC : JOBS)) + echo "Executing $testName" case $testName in test-stable) - _ "$cargo" stable test --jobs "$NPROC" --all --exclude solana-local-cluster ${V:+--verbose} -- --nocapture + _ "$cargo" stable test --jobs "$JOBS" --all --exclude solana-local-cluster ${V:+--verbose} -- --nocapture ;; test-stable-bpf) # Clear the C dependency files, if dependency moves these files are not regenerated diff --git a/scripts/coverage.sh b/scripts/coverage.sh index fea0d79bf9..ec6b46373c 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -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=$?