Skip to content

Commit

Permalink
Limit compiler jobs if the machine has lower than 4gb/thread (solana-…
Browse files Browse the repository at this point in the history
  • Loading branch information
sakridge authored Jan 28, 2022
1 parent 40a4908 commit 1b7bc8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 5 additions & 4 deletions ci/test-stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$?
Expand Down

0 comments on commit 1b7bc8b

Please sign in to comment.