Repository navigation
perf(sessioncmd): answer a board read's liveness and directory in one tmux call - #305
Merged
Merged
Conversation
… 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>
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.
Why
Board extensions read the sessions they watch on every poll pass, and each read forks
tmuxtwo or three times. In a 60 sexecsnoopof a live board with 149 sessions, 1,345 forks a minute weretmux has-session -t gi_<id>, and every one of them was followed by a second fork for the same session.Summary
BoardGetcalledExists(has-session) and then, for a live pane,PaneCurrentPath(list-panes -F #{pane_current_path}).BoardReaddid both of those and alsocapture-pane. Thehas-sessioncount matches that exactly: 828 Gets plus 517 Reads (the 517capture-paneper minute in the same trace) is 1,345.Driver.LivePaneDirreads#{pane_id} #{pane_current_path}in one call. A pane id coming back counts as proof of life, the same testExistsalready applies to an adopted pane, wheredisplay-messageexits 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.currentInforeplaces everysessionInfo(x, driver.Exists(x.ID), …)insessioncmd(get, mute, accounts, adopt, replace), andBoardReaduses it before capturing.sessionInfoInsplit 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
TestBoardGetAndReadForkOnceForLivenesscounts thetmuxprocesses each read forks, through a logging shim:BoardGet, live sessionBoardRead, live sessionBoardGet, dead sessionOn the board measured above, that removes the 1,345/min
has-sessionline, about 30% of every fork the board made. Liveexecsnoopfigures after deploy will be added in a comment.Test plan
TestBoardGetAndReadForkOnceForLiveness: fails onmain(2 and 3 forks), passes here; also checks that the reported directory follows a pane thatcd'd, and that a dead row keeps its stored directoryTestLivePaneDirAgreesWithExists: managed live, adopted live, adopted closed and never-created ids all give the same liveness asExistsgo test -count=1 ./internal/tmux/ ./internal/sessioncmd/ ./internal/extensionhost/andgo test -short ./internal/ui/pass, run withenv -u TMUX -u TMUX_PANEand a scratchTMUX_TMPDIR🤖 Generated with Claude Code