Repository navigation
test(bench): assert the worker join, not just the taken handle - #847
Merged
Merged
Conversation
`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. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016uTUQ2a6B1Hscropr8rvt6
5 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Adds one assertion to
stop_joins_worker_and_treats_kill_as_clean_shutdownsoit actually guards the join that gives it its name.
Why
Follow-up to #845 (merged), which was correct — this is a gap in its test, not
in its fix.
The test asserted
bencher.worker.is_none()and that the signal stayedKill.Both hold as soon as the handle is taken, whether or not it is joined, so the
Killhalf of #845 was guarded and the join half was not. Verified by mutationon the merged commit:
Killearly-return in the workerlet _ = self.worker.take();Arc::strong_count(&bencher.signal) == 1closes it. The worker holds its ownclones 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
genuinely finished.
How it was verified
cargo fmt --allcargo lint(via the pre-commit hook — workspace,--all-targets)cargo test -p wingfoil --lib --features bench(87 passed)cargo test -p wingfoil --all-features(not run: needsprotoc; CI covers it)Mutation-checked both ways, which is the point of the change: the new assertion
passes 5/5 runs with the join in place and fails 8/8 with the join removed.
Notes for the reviewer
One deliberate non-goal:
Bencherstill has noDrop, so if criterion panicsbetween
start()andstop()theALWAYS-activated worker keeps spinning acore for the life of the process. That is pre-existing rather than introduced by
#845, and it is a behaviour change rather than a test fix, so it is left out of
this PR. Happy to open it separately if wanted.
Generated by Claude Code