Nacre/tools/mem-run.sh

20 lines
924 B
Shell
Executable file

#!/usr/bin/env bash
# Nacre's memory on the tune site list: tools/mem-run.sh <outdir> [ENV=value ...]
# Runs tests/smoke/tune-mem.txt hidden (tools/smoke.sh) while tools/engine-test/sample.py samples the process tree
# into <outdir>/samples.csv. Extra arguments are environment overrides (NACRE_WK_PAGE_CACHE=1, ...). Needs internet.
# Never alongside cargo or another engine run.
set -u
root=$(cd "$(dirname "$0")/.." && pwd)
out=${1:?usage: mem-run.sh <outdir> [ENV=value ...]}
shift
if pgrep -a cargo; then echo "mem-run: cargo is running" >&2; exit 2; fi
rm -rf "$out"
mkdir -p "$out"
out=$(cd "$out" && pwd)
python3 "$root/tools/engine-test/sample.py" --out "$out/samples.csv" --name 'release/nacre$' --mark-log "$out/smoke/selftest.log" --until-gone &
sampler=$!
env "$@" SMOKE_TIMEOUT=400 "$root/tools/smoke.sh" "$root/tests/smoke/tune-mem.txt" "$out/smoke"
status=$?
sleep 3
kill "$sampler" 2>/dev/null
exit $status