Skip to content

Commit 1310e3b

Browse files
authored
�[bench] clean up temp files even in case of error (#5106)
1 parent 0d49ecf commit 1310e3b

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

benchmark/sirun/runall.sh

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
set -e
44

5+
DIRS=($(ls -d */ | sed 's:/$::')) # Array of subdirectories
6+
CWD=$(pwd)
7+
8+
function cleanup {
9+
for D in "${DIRS[@]}"; do
10+
rm -f "${CWD}/${D}/meta-temp.json"
11+
done
12+
}
13+
14+
trap cleanup EXIT
15+
516
# Temporary until merged to master
617
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 \
718
&& tar -xzf sirun.tar.gz \
@@ -36,13 +47,11 @@ SPLITS=${SPLITS:-1}
3647
GROUP=${GROUP:-1}
3748

3849
BENCH_COUNT=0
39-
for D in *; do
40-
if [ -d "${D}" ]; then
41-
cd "${D}"
42-
variants="$(node ../get-variants.js)"
43-
for V in $variants; do BENCH_COUNT=$(($BENCH_COUNT+1)); done
44-
cd ..
45-
fi
50+
for D in "${DIRS[@]}"; do
51+
cd "${D}"
52+
variants="$(node ../get-variants.js)"
53+
for V in $variants; do BENCH_COUNT=$(($BENCH_COUNT+1)); done
54+
cd ..
4655
done
4756

4857
GROUP_SIZE=$(($(($BENCH_COUNT+$SPLITS-1))/$SPLITS)) # round up
@@ -56,39 +65,30 @@ if [[ ${GROUP_SIZE} -gt 24 ]]; then
5665
exit 1
5766
fi
5867

59-
for D in *; do
60-
if [ -d "${D}" ]; then
61-
cd "${D}"
62-
variants="$(node ../get-variants.js)"
68+
for D in "${DIRS[@]}"; do
69+
cd "${D}"
70+
variants="$(node ../get-variants.js)"
6371

64-
node ../squash-affinity.js
72+
node ../squash-affinity.js
6573

66-
for V in $variants; do
67-
if [[ ${BENCH_INDEX} -ge ${BENCH_START} && ${BENCH_INDEX} -lt ${BENCH_END} ]]; then
68-
echo "running $((BENCH_INDEX+1)) out of ${BENCH_COUNT}, ${D}/${V} in background, pinned to core ${CPU_AFFINITY}..."
74+
for V in $variants; do
75+
if [[ ${BENCH_INDEX} -ge ${BENCH_START} && ${BENCH_INDEX} -lt ${BENCH_END} ]]; then
76+
echo "running $((BENCH_INDEX+1)) out of ${BENCH_COUNT}, ${D}/${V} in background, pinned to core ${CPU_AFFINITY}..."
6977

70-
export SIRUN_VARIANT=$V
78+
export SIRUN_VARIANT=$V
7179

72-
(time node ../run-one-variant.js >> ../results.ndjson && echo "${D}/${V} finished.") &
73-
((CPU_AFFINITY=CPU_AFFINITY+1))
74-
fi
80+
(time node ../run-one-variant.js >> ../results.ndjson && echo "${D}/${V} finished.") &
81+
((CPU_AFFINITY=CPU_AFFINITY+1))
82+
fi
7583

76-
BENCH_INDEX=$(($BENCH_INDEX+1))
77-
done
84+
BENCH_INDEX=$(($BENCH_INDEX+1))
85+
done
7886

79-
cd ..
80-
fi
87+
cd ..
8188
done
8289

8390
wait # waits until all tests are complete before continuing
8491

85-
# TODO: cleanup even when something fails
86-
for D in *; do
87-
if [ -d "${D}" ]; then
88-
unlink "${D}/meta-temp.json" 2>/dev/null
89-
fi
90-
done
91-
9292
node ./strip-unwanted-results.js
9393

9494
if [ "$DEBUG_RESULTS" == "true" ]; then

0 commit comments

Comments
 (0)