Skip to content

perf(sessions): skip the pty list socket probe when the pid already proves life - #118

Merged
myobie merged 1 commit into
mainfrom
perf/list-skip-socket-probe-when-pid-alive
Jul 22, 2026
Merged

perf(sessions): skip the pty list socket probe when the pid already proves life#118
myobie merged 1 commit into
mainfrom
perf/list-skip-socket-probe-when-pid-alive

Conversation

@myobie

@myobie myobie commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Skip the pty list socket probe when the pid already proves life

Follow-up to #117 — perf/robustness hygiene, behavior-preserving.

listSessions computed socketReachable unconditionally, so pty list
did a wasted per-session socket connect for every live-pid entry: the probe
result is ignored (the session is reported running either way), and it adds
exactly the socket-connect contention that turns flaky under concurrent
multi-agent list load.

Change (one line): probe the control socket ONLY when the pid doesn't
already prove life:

const socketReachable = pidAlive ? true : await isSocketReachable(socketPath);

For a dead-looking or unreadable pid the socket is still the deciding signal
(the #117 reachable-socket rescue), so the correctness contract is unchanged —
only the wasted probe on the hot path is removed.

Verification: full suite green (1417 passed, 21 skipped), typecheck clean.
Mirrors the pty-rust port (4fba12f), which already probes only when the pid
looks dead. Defense-in-depth for the concurrent multi-agent load #117 addressed.

…s life

`listSessions` computed `socketReachable` unconditionally, so `pty list` did a
wasted per-session socket connect for every live-pid entry — the probe result
is ignored (running either way) and it adds exactly the socket-connect
contention that gets flaky under concurrent multi-agent list load. Probe the
control socket ONLY when the pid doesn't already prove life (dead-looking /
unreadable), where it is the deciding signal (the #117 reachable-socket rescue).

Behavior-preserving: full suite green (1417 passed), typecheck clean. Mirrors the
pty-rust port's approach (4fba12f). Genuine defense-in-depth for the hot list
path under the concurrent multi-agent load #117 was about.
@myobie
myobie merged commit 6de7884 into main Jul 22, 2026
1 of 2 checks passed
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