Skip to content

bench: check for processes left behind after the server stops - #495

Open
AmrDab wants to merge 2 commits into
mainfrom
feat/bench-leftovers
Open

AmrDab wants to merge 2 commits into
mainfrom
feat/bench-leftovers

Conversation

@AmrDab

@AmrDab AmrDab commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Summary

The benchmark gave each task a fresh daemon and then killed its whole process tree, so nothing a server left running could show. A real host never kills the tree: the server exits by itself. This PR adds a leftovers check to every run.

  • End of the run. One process-table read lists the daemon's descendants, with their count, names and MB.
  • Idle (Windows). The daemon runs with CLAWD_BRIDGE_IDLE_MS=5000, a knob from fix(windows): stop the idle PowerShell bridge after 10 minutes #490. The runner waits up to 8 s for the PowerShell UIA bridge to stop. Builds without the knob keep the bridge, and the row says so.
  • Stop like a host. On Windows this is POST /stop; on macOS and Linux it is SIGTERM. Then up to 3 s for helpers that end on their stdin's EOF.
  • Survivors. A process counts if it was in the daemon's tree (same pid and creation time, so a reused pid never counts) or its command line holds the run's temp home (the agent browser's profile is under it). It never matches by image name. Survivors fail the row. The runner then kills exactly those pids, falls back to a tree kill, and leaves nothing behind.
  • Report. Under each model's table, the report shows processes and MB at the end of the run, whether the bridge was still there after the idle wait, and any survivors. A total also goes in the summary line. With repeats, the worst run counts.

Ctrl+C and crashes keep the immediate tree kill. A failed process-table read leaves the row unmeasured rather than claiming nothing was left.

Testing

  • tsc -p tsconfig.tests.json passes.
  • npx vitest run bench passes (339 tests). This includes the new unit tests: table parsing, descendants, survivor matching, the gate and the report.
  • New real-process test: a parent spawns a detached child and exits, and the child is found as a survivor by pid plus start time and by the temp home. The test kills only what it started.
  • No live benchmark run yet: one announced run comes after review.

Pairs with #490 (the idle knob). Without #490 the idle line reports the bridge still running.

🤖 Generated with Claude Code

AmrDab and others added 2 commits November 29, 2026 18:12
Snapshot the isolated daemon's descendants when the agent ends (count, image
names, memory), wait for the PowerShell bridge to stop when idle
(CLAWD_BRIDGE_IDLE_MS=5000), stop the daemon like a host does (POST /stop on
Windows, SIGTERM elsewhere) and list survivors by pid + creation time or by the
run's temp home. A row with survivors fails the gate; they are then killed
individually, with the tree kill as a fallback.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nreadable table claims nothing

The pill, glow and bridge end on their stdin's EOF a moment after the daemon exits: read once at once, they showed as
survivors. A process table that cannot be read after the stop now leaves the row unmeasured instead of "none left".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread bench/lib/isolated.ts Resolved

This branch has not been deployed

No deployments
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.

2 participants