Benchmark Driver Temp Directories
Where the cross-engine benchmark drivers keep their files, how those files are removed, and how to remove a leftover safely.
Executive Summary
- Owned directories — each driver run writes to a temp directory of its own, marked with the process that made it
- Reaped on any end — a detached reaper removes it however the driver ends,
SIGKILLincluded, unless--keep-tempkeeps it - Safe cleanup —
node scripts/lib/owned-temp-dir.js --clean-staleremoves leftovers by marker; neverrm -rfa shared prefix
Directories and Their Reapers
The cross-engine drivers, scripts/awfy-driver.js,
scripts/jetstream-driver.js and scripts/web-tooling-driver.js, write their
bundles, binary copies and counter files to a directory of their own under the
system temp directory (goccia-awfy-…, goccia-jetstream-…,
goccia-web-tooling-…), made by scripts/lib/owned-temp-dir.js. Each holds a
.goccia-temp-owner.json marker naming the process that made it: its pid,
start time and PID namespace, and the machine id and host.
Each directory also gets a reaper, a small detached Node process that removes
it once the driver has ended, however it ends: it returns, throws, or is
stopped by SIGINT, SIGTERM or even SIGKILL. The driver keeps Node's own
signal behaviour, so a signal stops it at once, between samples or during
one, and no further sample starts; a sample's process already running is not
the driver's to stop and goes on by itself. --keep-temp (--keep-bundles
for web-tooling) keeps the directory on purpose, with no reaper, and the
driver prints its path.
A directory is left behind only when its reaper is killed too, the machine
loses power, a signal arrives in the moment between making the directory and
starting its reaper, or the reaper cannot remove a file within its ten tries,
half a second apart (on Windows, a file that a sample which outlived the driver
still holds open). Removal takes the marker last, so a directory left part
way keeps it. Several runs share each prefix, so never remove
leftovers by prefix (rm -rf /tmp/goccia-awfy-*): that also deletes the live
directories of every other run on the machine. Remove them by their marker
instead:
node scripts/lib/owned-temp-dir.js --clean-stale --dry-run # what it would removenode scripts/lib/owned-temp-dir.js --clean-stale # directories whose owner has endednode scripts/lib/owned-temp-dir.js --clean-stale --include-kept
It removes only directories whose owner has ended on this machine (the same
host and machine id) and, on Linux, in this PID namespace: the owner's pid is
gone, or now belongs to a process that started at another time. It leaves kept
ones unless --include-kept is given. Without /proc (macOS, Windows) the
host name stands for the machine, so two machines of one name must not share
a temp directory. A
goccia- directory without a marker it can read, or one whose owner it cannot
judge, is listed and left alone. It exits 1 when it cannot read the temp
directory or remove one it chose. To own everything a run makes, give the run
a temp directory of your own and remove that afterwards:
scratch="$(mktemp -d)"TMPDIR="$scratch" node scripts/awfy-driver.js …rm -rf "$scratch"