Repository navigation
feat(runtime): add worker lifetime leases for external owners - #1303
Conversation
|
Two independent read-only reviews (concurrency/lifetime and API/contracts/tests)
Both concerns are accepted. Deterministic regressions and owner-aware routing |
|
The refreshed API/contracts review has no blocking objection to the routing-fix The scenario was reproduced deterministically with a producer suspended on an The next revision restores ownership at generator consumer transfers and keeps |
|
The latest revision addresses the two additional independent-review blockers:
Self-audit additionally reproduced and fixed leased group-join rejection |
|
Two independent read-only reviews of the current revision, covering The reviews covered admission versus retirement/shutdown, pin accounting, Current-revision local evidence:
Residual limits: the focused runs are not an exhaustive concurrency proof; Full current-revision regression and CI completion remain required before the |
|
The current revision also passes the complete locally configured core regression suite: 1070 test cases, 22977 assertions, RNG seed 1301, with TLS/HTTP/HTTP2 disabled. Focused ASAN+UBSAN and TSAN checks and both independent review verdicts cover this same revision. The broader CI matrices are still running and remain required. |
|
All current-revision CI checks are now complete and successful, including the The two independent read-only no-blocker reviews, focused sanitizer results, |
|
Scope is now explicitly limited to worker-lifetime leases. Native ublk integration (#1302) is closed as not planned, and no public low-level io_uring API is included. Final validation of the unchanged implementation revision:
The implementation has not changed since the two independent no-blocker reviews and successful CI. All checks remain complete (the README-only check is intentionally skipped), there are no review threads or inline objections, and the PR is mergeable. It remains unmerged for maintainer consideration. External ring progress, cancellation, fairness, and protocol recovery remain application responsibilities. |
Description
Add an explicit worker-lifetime contract for long-lived external thread-affine
owners. Affinity remains a placement request; a lease retains an exact-owner
continuation and contributes to worker retirement accounting even when no
native I/O is pending.
Type of Change
Related Issues
Closes #1301
Native ublk integration and a public low-level io_uring API are out of scope;
#1302 was closed as not planned. External owners may use independently created
raw rings, with their progress and teardown managed by the application.
Changes Made
Core Changes
runtime::lease_current_worker()and move-onlyexternal_worker_lease.reuse existing logical-task pin and context active-operation accounting.
outlive forced scheduler teardown without dereferencing a dead scheduler.
so a repeatedly yielding owner cannot starve native I/O or maintenance.
API Changes
Previously, public affinity APIs could not retain an external owner's worker.
Serialized foreign-thread release is supported. Moving a token retains the
original logical task's constraint; it does not transfer routing to another
task. Forced shutdown and the existing graceful timeout policy remain
non-graceful escape hatches. A lease does not drive external completion queues.
Migration Guide
Additive API; no migration required for existing callers. The new worker-lease
guide documents caller responsibilities and shutdown boundaries.
Testing
Unit Tests
admission, bounded yielding-owner service, move/multiple/idempotent release,
foreign release, graceful waiting, forced teardown, off-worker rejection,
exception unwind, and distinct scheduler generations.
coverage: 19 test cases, 119 assertions; 20 repeated seeded runs pass. Explicit
io_uring coverage is included and reports unavailability as a skip.
assertions with RNG seed 1301 (TLS/HTTP/HTTP2 disabled). CI's broader protocol
and architecture matrices remain required.
Integration Tests
worker_leaseexample shrinks the pool and cleans up on worker 1.Sanitizer Testing
halt-on-error enabled (normal Debug dependency libraries).
(normal Debug dependency libraries).
Checklist
Code Quality
Documentation
Compatibility
Performance
acquire the endpoint mutex; no per-I/O lease acquisition/release is needed.
Additional Notes
Independent review found two owner-routing composition defects in the initial
revision. Both were reproduced by deterministic regressions before the routing
fix. Fresh-thread notification/cancellation, different-scheduler notification,
isolated-scope return, both directions of generator producer/consumer transfer,
blocking/timer/group completion rejection, captured blocking endpoint release,
stale foreign endpoint dispatch, and concurrent release/context destruction
are now covered. Two fresh independent read-only reviews report no blocking objections for
the current implementation, with residual coverage limits recorded in the
review comment.
The focused validation does not prove every concurrency interleaving. All
current-revision CI checks have now completed successfully, including both
architectures and build types. The README-only job was intentionally skipped
by path filtering. There are no unresolved review threads; the PR is ready for
maintainer consideration and has not been merged.
Reviewer Guidance
Focus on lock ordering, admission versus shrink/shutdown, cross-thread final
release versus context destruction, exact-owner routing for suspended tasks,
and progress of repeatedly requeued owners during drain. Check caller/library
boundaries, particularly moving a token versus transferring a logical task.