Skip to content

Commit 708b627

Browse files
authored
[bench] detect number of CPU cores dynamically (#5104)
1 parent 6adf121 commit 708b627

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

benchmark/sirun/runall.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ nvm use 18
2727
# run each test in parallel for a given version of Node.js
2828
# once all of the tests have complete move on to the next version
2929

30-
export CPU_AFFINITY="${CPU_START_ID:-24}" # Benchmarking Platform convention
30+
TOTAL_CPU_CORES=$(nproc 2>/dev/null || echo "24")
31+
export CPU_AFFINITY="${CPU_START_ID:-$TOTAL_CPU_CORES}" # Benchmarking Platform convention
3132

3233
nvm use $MAJOR_VERSION # provided by each benchmark stage
3334
export VERSION=`nvm current`
3435
export ENABLE_AFFINITY=true
3536
echo "using Node.js ${VERSION}"
36-
CPU_AFFINITY="${CPU_START_ID:-24}" # reset for each node.js version
37+
CPU_AFFINITY="${CPU_START_ID:-$TOTAL_CPU_CORES}" # reset for each node.js version
3738
SPLITS=${SPLITS:-1}
3839
GROUP=${GROUP:-1}
3940

@@ -54,7 +55,7 @@ BENCH_END=$(($GROUP_SIZE*$GROUP))
5455
BENCH_START=$(($BENCH_END-$GROUP_SIZE))
5556

5657
if [[ ${GROUP_SIZE} -gt 24 ]]; then
57-
echo "Group size ${GROUP_SIZE} is larger than available number of CPU cores on Benchmarking Platform machines (24 cores)"
58+
echo "Group size ${GROUP_SIZE} is larger than available number of CPU cores on Benchmarking Platform machines (${TOTAL_CPU_CORES} cores)"
5859
exit 1
5960
fi
6061

0 commit comments

Comments
 (0)