diff --git a/spike/x86/cost.sh b/spike/x86/cost.sh index 5b9b105..8bc0f35 100755 --- a/spike/x86/cost.sh +++ b/spike/x86/cost.sh @@ -54,8 +54,15 @@ test -x "$flan" || { echo "build failed" >&2; exit 1; } # Not mktemp under /tmp by default: this writes a few hundred executables of # a megabyte or two, and a full /tmp on this machine has already frozen one # session. The guard is cheap and a wedged run is not. -out=${COST_OUT:-${TMPDIR:-/tmp}/flan-cost.$$} -mkdir -p "$out" || exit 1 +# A directory of this run's own, made with a plain mkdir so that a second +# copy of this script cannot land in the first one's: two runs sharing a +# scratch directory overwrite each other's `l` and `x` between the build and +# the timing, and the result is a row of numbers that belong to two different +# programs. That happened once here and the numbers looked entirely ordinary. +work=${COST_OUT:-${TMPDIR:-/tmp}/flan-cost} +mkdir -p "$work" || exit 1 +out=$work/run.$$ +mkdir "$out" || exit 1 trap 'rm -rf "$out"' EXIT free=$(df -Pk "$out" | awk 'NR==2 {print $4}') [ "$free" -gt 2000000 ] || { echo "less than 2GB free at $out" >&2; exit 1; }