Skip to content

perf(sessioncmd): answer a board read's liveness and directory in one tmux call - #305

Merged
tfyl merged 1 commit into
mainfrom
perf/exists-from-scan
Oct 11, 2026
Merged

tfyl merged 1 commit into
mainfrom
perf/exists-from-scan

Conversation

@tfyl

@tfyl tfyl commented Oct 9, 2026

Copy link
Copy Markdown
Member

Why

Board extensions read the sessions they watch on every poll pass, and each read forks tmux two or three times. In a 60 s execsnoop of a live board with 149 sessions, 1,345 forks a minute were tmux has-session -t gi_<id>, and every one of them was followed by a second fork for the same session.

Summary

  • BoardGet called Exists (has-session) and then, for a live pane, PaneCurrentPath (list-panes -F #{pane_current_path}). BoardRead did both of those and also capture-pane. The has-session count matches that exactly: 828 Gets plus 517 Reads (the 517 capture-pane per minute in the same trace) is 1,345.
  • The new Driver.LivePaneDir reads #{pane_id} #{pane_current_path} in one call. A pane id coming back counts as proof of life, the same test Exists already applies to an adopted pane, where display-message exits 0 with an empty line once the pane has closed. A live pane whose directory can't be read still counts as live and falls back to the row's directory, as before.
  • runtime.currentInfo replaces every sessionInfo(x, driver.Exists(x.ID), …) in sessioncmd (get, mute, accounts, adopt, replace), and BoardRead uses it before capturing.
  • This adds the same sessionInfoIn split as perf(sessioncmd): read every listed session's directory from one tmux call #301, hunk for hunk, so whichever of the two merges second merges cleanly.

Numbers

TestBoardGetAndReadForkOnceForLiveness counts the tmux processes each read forks, through a logging shim:

read before after
BoardGet, live session 2 1
BoardRead, live session 3 2
BoardGet, dead session 1 1

On the board measured above, that removes the 1,345/min has-session line, about 30% of every fork the board made. Live execsnoop figures after deploy will be added in a comment.

Test plan

  • TestBoardGetAndReadForkOnceForLiveness: fails on main (2 and 3 forks), passes here; also checks that the reported directory follows a pane that cd'd, and that a dead row keeps its stored directory
  • TestLivePaneDirAgreesWithExists: managed live, adopted live, adopted closed and never-created ids all give the same liveness as Exists
  • go test -count=1 ./internal/tmux/ ./internal/sessioncmd/ ./internal/extensionhost/ and go test -short ./internal/ui/ pass, run with env -u TMUX -u TMUX_PANE and a scratch TMUX_TMPDIR
  • Nothing the board draws changes, so this PR has no capture

🤖 Generated with Claude Code

… tmux call

Get forked `has-session` and then `list-panes -F #{pane_current_path}`;
ReadPane forked both and the capture. Board extensions run these for every
session they watch on every poll pass. LivePaneDir reads the pane id and
directory together, the pane id standing as proof of life the way Exists
already takes it for an adopted pane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tfyl tfyl added the claude PR primarily authored by Claude label Oct 9, 2026
@tfyl
tfyl merged commit 99c9f3f into main Oct 11, 2026
7 checks passed
@tfyl
tfyl deleted the perf/exists-from-scan branch October 11, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR primarily authored by Claude

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant