Skip to content

Wait only for this run's vlt background processes - #222

Merged
lukekarrys merged 2 commits into
mainfrom
lk/vlt-wait-own-run
Nov 18, 2026
Merged

lukekarrys merged 2 commits into
mainfrom
lk/vlt-wait-own-run

Conversation

@lukekarrys

Copy link
Copy Markdown
Member

Problem

vlt_background_running (suite/scripts/vlt-background.sh), used by wait_for_vlt_background in clean-helpers.sh and by add-remove-state.sh, matched every process of the current user whose name starts with vlt- or whose command line is a /vlt/<name>-src-<name>.js script. In CI that is only the benchmark's own processes. On a shared machine (several benchmark audits running as the same user, plus the user's own vlt commands) one run could wait on another checkout's vlt-cache-unzip, and after 300 s the clean-helpers.sh wait_for_vlt_background dispatcher pkilled every vlt-cache-unzip of the user, including other runs'.

Fix

  • variations/common.sh and registry/common.sh export a unique BENCH_RUN_ID (<epoch>-<pid>-<random>) if unset. Every process the run starts inherits it: hyperfine's prepare/setup/cleanup, add-remove-state.sh, process-count.sh and its strace'd install, and vlt itself. All five of vlt 1.8.0's detached spawns (cache-unzip, registry-client revalidate, rollback-remove, security-archive, cli-sdk update-check) pass { ...process.env } to the child, so the children carry it too.
  • vlt-background.sh gains vlt_background_pids: the existing name and command-line pgreps remain the first filter; when BENCH_RUN_ID is set, a pid only counts if /proc/<pid>/environ contains BENCH_RUN_ID=<this run's id>. A process that exits between pgrep and the read, or whose environ is unreadable, is not treated as ours. vlt_background_running is now [ -n "$(vlt_background_pids)" ], so add-remove-state.sh is scoped too without changes.
  • clean-helpers.sh gains stop_vlt_background, which kills only the matched pids; the dispatcher's timeout path uses it instead of pkill -u <uid> vlt-cache-unzip. Since the wait covers all of the run's vlt children, the stop now covers the same set (before, only vlt-cache-unzip).
  • BENCH_RUN_ID unset (a script run by hand): today's behaviour, every vlt child of the user counts.

The id is per variation script (each sources one of the two common.sh). A variation's last --cleanup and its closing wait_for_vlt_background clean_all already wait for its own children before the next variation starts, so a new id per variation doesn't let work spill over.

Verified

  • node --test suite/scripts/: 41 pass. New tests in clean-helpers.test.js start fake vlt-cache-unzip / *-src-*.js children with or without a BENCH_RUN_ID and check that: a child of this run is waited for; children of another run or of no run are ignored and not killed by stop_vlt_background while this run's are; with no run id the helper waits for any run's child (fallback); vlt_background_running matches each of the three child shapes only for its own run.
  • Real inheritance check, run inside unshare --user --map-root-user --mount --fork with the work dir bind-mounted outside /home, a fresh tmpfs on /home, HOME=/home/runner, npm_config_*/XDG_* unset, asserting [ ! -e /home/luke ] before the install: BENCH_RUN_ID=x vlt install --registry=https://registry.npmjs.org/ on a 3-dependency project; the detached child pid=1971788 comm=vlt-cache-unzip had BENCH_RUN_ID=x and HOME=/home/runner in /proc/<pid>/environ. The host's ~/.cache/vlt mtime was unchanged afterwards. A first attempt also caught a vlt-cache-unzip from another benchmark audit running on the same box in a sibling namespace, whose environ was unreadable: exactly the case the id filter now excludes.

🤖 Generated with Claude Code

vlt_background_running matched every vlt child of the current user, so on
a shared machine one benchmark run could wait on, or after 300s stop,
another checkout's (or the user's own) vlt-cache-unzip.

Each run now exports a unique BENCH_RUN_ID (variations/common.sh,
registry/common.sh). vlt passes process.env to its detached children, so
they inherit it, and vlt_background_pids only counts processes whose
/proc/<pid>/environ holds this run's id (after the existing name and
command-line match). The kill path stops only those pids. With
BENCH_RUN_ID unset, behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
benchmarks Ready Ready Preview Nov 18, 2026 8:37am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

# Conflicts:
#	suite/scripts/clean-helpers.test.js
@lukekarrys

Copy link
Copy Markdown
Member Author

Merged main into this branch to pick up #223, which conflicted in suite/scripts/clean-helpers.test.js: both PRs added code at the same spot. I kept both: #223's clean_node_modules test, and this PR's baseEnv/helperEnv helpers. node --test suite/scripts/: 42 pass. Both changes had clean CI on their own; this merge combines independent functions in clean-helpers.sh.

🤖 Generated with Claude Code

@lukekarrys
lukekarrys merged commit 0b3a2dc into main Nov 18, 2026
1 of 2 checks passed
@lukekarrys
lukekarrys deleted the lk/vlt-wait-own-run branch November 18, 2026 08:37

This branch was previously deployed

1 inactive deployment
Benchmark — 4b1defdc Deployed Nov 18, 2026 by lukekarrys via Run Benchmarks (build-cache, next) #1464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant