Repository navigation
Send terminal catalogue changes as deltas - #109
Merged
Merged
Conversation
run_terminal_watch answered every catalogue revision with RESET plus a full snapshot, one record per event, to every watcher. Diff the previous and current catalogues by handle and send one DELTA of ADD/REPLACE/REMOVE records instead, falling back to RESET plus snapshot only when the delta exceeds the event limit, as run_client_watch already does.
Contributor
There was a problem hiding this comment.
Ultimator's review of 11605b6
The terminal watch now diffs the previous and current TerminalCatalogue by handle and sends one Phase::Delta event. It falls back to RESET plus snapshot when the delta exceeds the event limit, as run_client_watch does. I found nothing wrong in the diff. I had no checkout and did not run the tests, so the new test and the changed cross-session close test still need CI to confirm.
No issues found.
Reviewed in 12s · Session · @ultimator-agent review reviews again · @ultimator-agent fix fixes the open issues
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.
run_terminal_watchresponded to every catalogue revision bump withPhase::Reset, followed by a fullsend_terminal_snapshot: BEGIN, then oneSNAPSHOT_RECORDSevent per terminal, then END. A single create, title/cwd change, exit or close therefore resent the whole catalogue to every terminal watcher. Each record was its own event, and clients ACK each event.The cost grows with the catalogue size. On a production box running hundreds of agent subagents, the catalogue held 1,033 terminals (9 running and 1,024 exited, retained under
DEFAULT_MAX_EXITED), at about 817 B per record. That made every terminal event about 0.8 MB and about 1,036 frames per watching connection. A 5s sample on the client counted 14 RESET, 14 BEGIN, 14,003 RECORDS, 14 END and 0 DELTA, and the client's event loop saturated.The terminal watch now does what
run_client_watchalready does.terminal_delta_eventdiffs the previous and currentTerminalCatalogueby handle and builds onePhase::Deltaevent:Addfor new handlesReplacefor changed recordsRemove(RemovedTerminal) for handles that are goneUnchanged records are not sent. If the delta doesn't fit the event limit, it falls back to RESET plus snapshot through
state_delta_reset, as the client watch does. Because thewatchchannel coalesces revisions, a delta can span several revisions (from_revision→to_revision).Consumers already handle terminal deltas:
@yas-run/core'sYasTerminalCatalog.apply(YAS_STATE_DELTAwith ADD/REPLACE/PATCH/REMOVE) and the CLI'swatch_terminal_exit.Tests:
terminal_catalogue_revision_is_one_delta_with_only_changed_records.terminal_cross_session_close_discards_frames_before_removal_statenow accepts the removal as a DELTARemovefor the closed handle, as well as the old reset path. It still asserts that no ADD/REPLACE of the closed terminal arrives and that no frame follows.cargo check -p yas-server --testsandcargo clippy -p yas-server --lib --tests -- -D warningspass, andrustfmt --checkis clean.rustclinking theyas-serverlib test. CI needs to confirm both tests.A follow-up could send
TerminalPatchwhen only extensions change, instead of a fullReplace.Tag
@indentto continue the conversation here.