Skip to content

Commit

Permalink
�[bench] clean up temp files even in case of error (#5106)
Browse files Browse the repository at this point in the history
  • Loading branch information
watson authored Jan 21, 2025
1 parent 0d49ecf commit 1310e3b
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions benchmark/sirun/runall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

set -e

DIRS=($(ls -d */ | sed 's:/$::')) # Array of subdirectories
CWD=$(pwd)

function cleanup {
for D in "${DIRS[@]}"; do
rm -f "${CWD}/${D}/meta-temp.json"
done
}

trap cleanup EXIT

# Temporary until merged to master
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 \
&& tar -xzf sirun.tar.gz \
Expand Down Expand Up @@ -36,13 +47,11 @@ SPLITS=${SPLITS:-1}
GROUP=${GROUP:-1}

BENCH_COUNT=0
for D in *; do
if [ -d "${D}" ]; then
cd "${D}"
variants="$(node ../get-variants.js)"
for V in $variants; do BENCH_COUNT=$(($BENCH_COUNT+1)); done
cd ..
fi
for D in "${DIRS[@]}"; do
cd "${D}"
variants="$(node ../get-variants.js)"
for V in $variants; do BENCH_COUNT=$(($BENCH_COUNT+1)); done
cd ..
done

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

for D in *; do
if [ -d "${D}" ]; then
cd "${D}"
variants="$(node ../get-variants.js)"
for D in "${DIRS[@]}"; do
cd "${D}"
variants="$(node ../get-variants.js)"

node ../squash-affinity.js
node ../squash-affinity.js

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

export SIRUN_VARIANT=$V
export SIRUN_VARIANT=$V

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

BENCH_INDEX=$(($BENCH_INDEX+1))
done
BENCH_INDEX=$(($BENCH_INDEX+1))
done

cd ..
fi
cd ..
done

wait # waits until all tests are complete before continuing

# TODO: cleanup even when something fails
for D in *; do
if [ -d "${D}" ]; then
unlink "${D}/meta-temp.json" 2>/dev/null
fi
done

node ./strip-unwanted-results.js

if [ "$DEBUG_RESULTS" == "true" ]; then
Expand Down

0 comments on commit 1310e3b

Please sign in to comment.