Per-session locking: stop holding the map lock across a pi turn #33
Labels
No labels
in-review
ready-for-agent
ready-for-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
weiwen/evie#33
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
SessionManager::send_messagetakes the session-map write lock and holds it across the entire pi turn, so a status check, the idle-cleanup task, or a message on another chat/interface all block for the full duration of an in-flight answer — defeating theRwLockthat was chosen for concurrent reads. Restructure so the map lock is held only briefly (lookup, or spawn-and-insert) and each turn holds only its own session's lock.Scoped single-user (ADR-0001), but the dual-interface overlap and status-during-turn cases are documented use cases, so the fix is worthwhile.
Decision from grilling:
PiProcess::spawnis awaited under the map lock (session creation is infrequent), the slot is inserted, itsArccloned, then the lock is dropped. The turn then locks onlyslot.process.last_activitylives outside the turn lock as an atomic, soget_statusandcleanup_idleread it under just the brief map read lock — they never block on a running turn.Arc::ptr_eqso a concurrently-replaced session is not clobbered.Acceptance criteria
Arc<Slot>; the turn'ssend_messageholds only the per-session lock, not the map lock.get_statusandcleanup_idlereadlast_activitywithout acquiring the per-session turn lock (verified: status returns while a turn is simulated in flight).just checkgreen.Blocked by
None - can start immediately.
Soft advisory: overlaps #31 in the session manager (session-id minting). Grabbing this after #31 avoids a merge collision — not a hard blocker.