Skip to content

refactor: clarify permit ownership and waiter state transitions - #433

Open
tisonkun wants to merge 6 commits into
apache:mainfrom
tisonkun:codex/clarify-ownership-and-wait-states
Open

tisonkun wants to merge 6 commits into
apache:mainfrom
tisonkun:codex/clarify-ownership-and-wait-states

Conversation

@tisonkun

@tisonkun tisonkun commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Route all four successful oneshot receive paths through the same acquire fence and payload transfer.
  • Share waker replacement across occupied registrations and return the retired waker to the caller for destruction after unlocking.
  • Consume single-use MPMC and SPMC benchmark batches when joining their workers.
  • Implement infallible singleflight and OnceMap operations through their respective fallible paths.
  • Give read-access tokens responsibility for acquiring their permits. A pending read stores its owner and queue registration together, including across cancellation.
  • Represent a Condvar wait as holding a guard, owning a waiter registration, or complete. The waiter is registered before the associated mutex is released.

Design Notes

The table compares the public futures immediately before and after the Condvar commit. Both rustc 1.86.0 and 1.101.0-nightly (8006091eb) produced these values on aarch64-apple-darwin. The probe used a release build with only the condvar feature and called size_of_val on the unboxed futures returned with borrowed and owned guards for Mutex<()>.

Public future Before (ca794f7) After (55d4ab9)
Condvar::wait 104 B 104 B
Condvar::wait_owned 96 B 96 B

On the same nightly target, the read-permit change also reduces RwLock::read and read_owned futures from 48 B to 32 B, and UpgradableRwLock::upgradable_read from 56 B to 48 B.

Validation passed with cargo x test on Rust 1.86.0 and nightly (707 tests each), cargo x check (26 feature configurations), cargo x lint, and the ecosystem, primitives, and upgradable-lock stage benchmark smoke checks.

The additional Linux-target Miri run passed all 11 Condvar integration tests with -Zmiri-ignore-leaks. The shared Tokio test runtime keeps worker threads alive at process exit on both sides of the Condvar change. The repository's standard Miri suite runs separately in CI with its normal leak checks.

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.

1 participant