Skip to content

Commit 435109b

Browse files
authored
fix(ci): Balance splits across benchmarking CI jobs according to the number of CPU cores (#5099)
* Fix how balancing over CPU cores works, so now tasks are split by variants instead of only directories * Fix bug with taskset trying to assign to non-existing core * Fix bug with off by 1 error in benchmarks count * Fail job with exit code 1 if sirun could not start it * Fail CI job when GROUP_SIZE is larger than number of CPU cores
1 parent 587957e commit 435109b

1 file changed

Lines changed: 31 additions & 26 deletions

File tree

benchmark/sirun/runall.sh

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
# Temporary until merged to master
46
wget -O sirun.tar.gz https://github.com/DataDog/sirun/releases/download/v0.1.10/sirun-v0.1.10-x86_64-unknown-linux-musl.tar.gz \
57
&& tar -xzf sirun.tar.gz \
@@ -34,46 +36,49 @@ echo "using Node.js ${VERSION}"
3436
CPU_AFFINITY="${CPU_START_ID:-24}" # reset for each node.js version
3537
SPLITS=${SPLITS:-1}
3638
GROUP=${GROUP:-1}
37-
BENCH_COUNT=0
3839

40+
BENCH_COUNT=0
3941
for D in *; do
4042
if [ -d "${D}" ]; then
41-
BENCH_COUNT=$(($BENCH_COUNT+1))
43+
cd "${D}"
44+
variants="$(node ../get-variants.js)"
45+
for V in $variants; do BENCH_COUNT=$(($BENCH_COUNT+1)); done
46+
cd ..
4247
fi
4348
done
4449

45-
# over count so that it can be divided by bash as an integer
46-
BENCH_COUNT=$(($BENCH_COUNT+$BENCH_COUNT%$SPLITS))
47-
GROUP_SIZE=$(($BENCH_COUNT/$SPLITS))
48-
49-
run_all_variants () {
50-
local variants="$(node ../get-variants.js)"
51-
52-
node ../squash-affinity.js
53-
54-
for V in $variants; do
55-
echo "running ${1}/${V} in background, pinned to core ${CPU_AFFINITY}..."
56-
57-
export SIRUN_VARIANT=$V
58-
59-
(time node ../run-one-variant.js >> ../results.ndjson && echo "${1}/${V} finished.") &
60-
((CPU_AFFINITY=CPU_AFFINITY+1))
61-
done
62-
}
50+
GROUP_SIZE=$(($(($BENCH_COUNT+$SPLITS-1))/$SPLITS)) # round up
6351

6452
BENCH_INDEX=0
6553
BENCH_END=$(($GROUP_SIZE*$GROUP))
6654
BENCH_START=$(($BENCH_END-$GROUP_SIZE))
6755

56+
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+
exit 1
59+
fi
60+
6861
for D in *; do
6962
if [ -d "${D}" ]; then
70-
if [[ ${BENCH_INDEX} -ge ${BENCH_START} && ${BENCH_INDEX} -lt ${BENCH_END} ]]; then
71-
cd "${D}"
72-
run_all_variants $D
73-
cd ..
74-
fi
63+
cd "${D}"
64+
variants="$(node ../get-variants.js)"
65+
66+
node ../squash-affinity.js
67+
68+
for V in $variants; do
69+
if [[ ${BENCH_INDEX} -ge ${BENCH_START} && ${BENCH_INDEX} -lt ${BENCH_END} ]]; then
70+
echo "running $((BENCH_INDEX+1)) out of ${BENCH_COUNT}, ${D}/${V} in background, pinned to core ${CPU_AFFINITY}..."
71+
72+
export SIRUN_VARIANT=$V
73+
74+
(time node ../run-one-variant.js >> ../results.ndjson && echo "${D}/${V} finished.") &
75+
((CPU_AFFINITY=CPU_AFFINITY+1))
76+
fi
77+
78+
BENCH_INDEX=$(($BENCH_INDEX+1))
79+
done
7580

76-
BENCH_INDEX=$(($BENCH_INDEX+1))
81+
cd ..
7782
fi
7883
done
7984

0 commit comments

Comments
 (0)