From 74299c8919cb2e2f6e1678817529e3a730cf6b81 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 12 Jan 2026 21:29:39 +0100 Subject: Automatically detect number of threads for unix systems --- build.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 642f5ca..e4da0b7 100755 --- a/build.sh +++ b/build.sh @@ -43,10 +43,23 @@ NODE=${NODE-${NISSY_BUILD_NODE:-"node"}} # The default value is 16. THREADS=${THREADS-${NISSY_BUILD_THREADS}} +portable_nproc() { + OS="$(uname -s)" + case "$OS" in + "Linux") + nproc + ;; + "Darwin" | "*BSD") + sysctl -n hw.ncpu + ;; + *) + echo "32" # A safe, large default + ;; + esac +} + detectthreads() { - # TODO: detect based on system - # Is 'getconf NPROCESSORD_ONLN' portable? Is it threads or cores? - echo "16" + echo "$(portable_nproc)" } [ -z "$THREADS" ] && THREADS="$(detectthreads)" -- cgit v1.3