From 00c9b6590db0d5f8af5ef48430d7d983f6a494e2 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Wed, 4 Sep 2024 18:30:14 -0700 Subject: [PATCH] validate.sh: `--jobs` should default to `nproc` If `nproc` is available and `--jobs` is not given, this will use the output of `nproc` as the value for `--jobs`. Otherwise, the old default value of 4 will be used and a warning will be printed. The default value of 4 has remained unchanged since it was added in 6a9a101ca5e1731b9f099a94579a84d2e19667f8 in 2018; that may have been a reasonable number of cores then, but my development machine today has 20 cores, so setting the parallelism to 4 leaves a lot of performance on the table! --- validate.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/validate.sh b/validate.sh index fc8586a3778..f0203dc2ede 100755 --- a/validate.sh +++ b/validate.sh @@ -12,7 +12,7 @@ # See https://github.com/haskell/cabal/issues/8049 HC=ghc CABAL=cabal -JOBS=4 +JOBS="" LIBTESTS=true CLITESTS=true CABALSUITETESTS=true @@ -293,6 +293,15 @@ fi # Adjust runtime configuration ####################################################################### +if [ -z "$JOBS" ]; then + if command -v nproc >/dev/null; then + JOBS=$(nproc) + else + echo "Warning: \`nproc\` not found, setting \`--jobs\` to default of 4." + JOBS=4 + fi +fi + TESTSUITEJOBS="-j$JOBS" JOBS="-j$JOBS"