#104 #98 sanitize_output returns Cow + VecDeque grid for O(1) scroll#114
Merged
kirich1409 merged 1 commit intomainfrom Apr 14, 2026
Merged
#104 #98 sanitize_output returns Cow + VecDeque grid for O(1) scroll#114kirich1409 merged 1 commit intomainfrom
kirich1409 merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR primarily targets performance on the PTY read hot path by making sanitize_output allocation-free when it’s a no-op, and updates session broadcasting to avoid an extra copy when sanitization produces an owned buffer. It also includes additional performance/test refactors in the REST layer and VT screen buffer.
Changes:
- Change
vt_parser::sanitize_outputto returnCow<[u8]>with a borrowed fast path and owned slow path, plus tests asserting the borrowed behavior. - Update
TerminalSessionbroadcasting to useBytes::from(sanitized.into_owned())to avoid a second copy when sanitization already allocated. - Add
Store::for_tests()and refactor multiple REST-related tests to use it; introduce cached system metrics (SysCache) in REST state.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| runner/src/vt_parser.rs | sanitize_output now returns Cow; additional ScreenBuffer storage/scrolling changes. |
| runner/src/session.rs | Broadcast path updated to leverage Cow and avoid extra allocations/copies. |
| runner/src/store.rs | Adds Store::for_tests() helper for in-memory SQLite + migrations. |
| runner/src/rest_handlers/sessions.rs | Test helpers updated to use Store::for_tests() and new AppState.sys_cache. |
| runner/src/rest_api.rs | Adds SysCache with TTL and threads it through AppState; refactors health/metrics to use the cache; test updates. |
| runner/src/main.rs | Wires sys_cache into the production AppState initialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2aefd5d to
77b7fd5
Compare
Closes #104 In the common case (no OSC-52 sequences) sanitize_output was allocating a Vec<u8> for every PTY read even though it returned data identical to the input. Changed return type to Cow<'_, [u8]>: borrows the input when nothing is removed, allocates only when an OSC-52 sequence is stripped. Also removes one extra copy in session.rs: Bytes::from(owned_vec) for the sanitized case vs Bytes::copy_from_slice for the no-op case.
77b7fd5 to
682ed72
Compare
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
Acceptance Criteria
#104
#98
Closes #104
Closes #98