Repository navigation
Share SSH commands between remote agent session stats - #600
Open
thiblahute wants to merge 1 commit into
Open
thiblahute wants to merge 1 commit into
thiblahute wants to merge 1 commit into
Conversation
Every remote session stat ran its own SSH command, and Herdr's agent list, polled every few seconds, stat'ed each agent's session each time. With many panes on one host these commands held the host's session slots, which slowed every other read on that connection, transcripts included. - Stats of remote session files asked together (a poll over every pane, a session's subagents) go out as one SSH command, up to 64 paths. A stat only joins a batch not sent yet, so its answer is never older than the call. - Over SSH, the activity time the agent list is sorted by is reused for 30 seconds while an agent's state stays. Also test that a Pi pane skips a session file named without an id.
This branch has not been deployed
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.
Summary
Remote agent session stats share SSH commands: stats asked together go out as one command, and the agent list reuses an agent's activity time for 30 seconds while its state stays. A follow-up to #563 and #564.
Why
Each stat of a session file on an SSH host ran its own SSH command.
agent.list, polled every few seconds, stat'ed every agent's session each time to filllast_activity_at, and a session's subagents are stat'ed one by one. With many agent panes on one host, these commands held the host's session slots, so opening a chat or reading a long transcript on that connection waited behind them.What changed
session-file-access.ts: a remotestatFilewaits 25 ms for others and goes out with them as onebash -cscript over SSH (up to 64 paths per command). The script answers a line per path:-for no file,!for an unreadable one, else the same metadata as before (GNU stat, else BSD stat). A stat only joins a batch that has not been sent, so its answer is never older than the call; the same path asked twice in a batch shares one answer. A failed command rejects every stat in it.agent-activity.ts: over SSH, an agent's activity time is reused for 30 seconds while its pane, session and state (agent_status,state_change_seq) stay; any state change stats again. Local connections stat as before.docs/ARCHITECTURE.md: the Agent activity section says both.Verification
bun test server/src/agent/: 147 pass. New: "stats asked together share one SSH command" (five concurrent stats, a missing file and a directory, one command; a later stat runs a new one), "a failed stat batch fails each of its stats", and "over SSH, reuses an agent's activity time while its state stays". All three fail onmain, as do the transcript tests whose SSH stub now answers in the batch format.bun run format:check,bun run lint(only the existingTerminalView.tsxwarning),bun run typecheck:bun.bun run test:quickwith an isolatedHOME/TMPDIR: the only failures are the two zsh tests (no zsh here), the worktree-removal process-scan timeout, and timeouts under load that pass when rerun alone.Manual checks
Compatibility
No stored format changes. The remote stat script now runs in
bash -cinstead of a login shell (bash -lc); it needs onlystat,base64andtr, as before.Also adds a regression test: a Pi pane skips a session file named without an id (the behaviour already on main since #565).