Repository navigation
fix(bench): join the worker during shutdown - #845
Conversation
Keep benchmark teardown deterministic by retaining and joining the worker handle while treating the intentional kill signal as a clean exit.
|
Merged — thank you, @snowyukitty. Nice diagnosis: treating the One follow-up, opened as #847, and it's a gap in the test rather than in your fix.
#847 adds Also noted there and deliberately left out: Generated by Claude Code |
`stop_joins_worker_and_treats_kill_as_clean_shutdown` guarded the `Kill` half of #845 but not the join it is named for: replacing the join with a bare `self.worker.take()` left the test passing, because taking the handle already satisfies both of its assertions. Assert `Arc::strong_count(&bencher.signal) == 1` instead. The worker holds its own clones of `signal` (the trigger's and the sink's), which drop with its stack, so the caller owning the last reference is observable only once the thread has actually finished. Verified by mutation: passes with the join, fails without it. Claude-Session: https://claude.ai/code/session_016uTUQ2a6B1Hscropr8rvt6 Co-authored-by: Claude <[email protected]>
What this changes
Keep the bencher worker's
JoinHandleand join it during orderly shutdown. A runner exit caused byKillis treated as expected, while a worker panic is resumed on the caller thread.Why
The worker was spawned and detached, so benchmark shutdown could return while it was still alive. Joining it makes teardown deterministic and avoids logging the intentional kill signal as an error.
Closes #833.
How it was verified
cargo fmt --allcargo lintcargo lint-all(not run: this machine does not haveprotoc)cargo test -p wingfoil --all-features(not run: all features requireprotoc)cargo test -p wingfoil --lib --features bench(85 passed)cargo clippy -p wingfoil --lib --features bench -- -D warningsgit diff --checkNotes for the reviewer
The focused regression test asserts that
stopconsumes the live worker handle, waits for its exit, and leaves the signal asKillrather than letting the old error path overwrite it withEnd.Disclosure: OpenAI Codex assisted with implementation and tests. The exact patch was independently reviewed by Grok and validated locally; no AI model is credited as a legal author.