Skip to content

perf(stream): drop the unread stdout copy in the CaptureOnly arm - #3850

Open
wilyan09007 wants to merge 1 commit into
rtk-ai:developfrom
wilyan09007:fix/stream-captureonly-clone
Open

wilyan09007 wants to merge 1 commit into
rtk-ai:developfrom
wilyan09007:fix/stream-captureonly-clone

Conversation

@wilyan09007

Copy link
Copy Markdown

Summary

  • run_streaming's CaptureOnly arm cloned all of raw_stdout into StreamResult.filtered, up to the 10 MiB RAW_CAP, on every capture-mode command.
  • Nothing reads filtered on that path: both CaptureOnly call sites (run_captured_filter in runner.rs, and uv_cmd) work off raw/raw_stdout/raw_stderr, and the three readers of filtered in runner.rs, git.rs and search.rs all sit on FilterMode::Streaming calls.
  • The arm now leaves filtered empty.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk <command> output inspected

test_run_streaming_capture_only_filtered_equals_raw asserted the copy existed. It is replaced by test_run_streaming_capture_only_leaves_filtered_empty, which spawns a child emitting ~1 MiB and checks that raw_stdout still carries it while filtered stays empty.

Fixes #3397

run_streaming's CaptureOnly branch finished reading the child's stdout into
raw_stdout and then cloned the whole buffer into StreamResult.filtered, up to
the 10 MiB RAW_CAP, on every capture-mode command.

Nothing reads it there. Both CaptureOnly call sites, run_captured_filter in
runner.rs and uv_cmd, work off raw, raw_stdout and raw_stderr; the three
readers of filtered (runner.rs, git.rs, search.rs) are all on
FilterMode::Streaming calls, and saved_filter, the one path that appends to
filtered after the read loop, is only set in the streaming branch.

Leave filtered empty there and say so on the field. The test that asserted the
copy existed now spawns a child emitting ~1 MiB and checks that raw_stdout
still carries it while filtered stays empty.

Signed-off-by: William <[email protected]>
@CLAassistant

CLAassistant commented Sep 3, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run_streaming's CaptureOnly arm clones the entire child stdout into a field no caller reads

2 participants