GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf(acp): long agent output lines are no longer re-split on every chunk by KiroshiAiviom · Pull Request #19609 · pingdotgg/t3code

Conversation

@KiroshiAiviom

@KiroshiAiviom KiroshiAiviom commented Oct 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Problem

The ACP stdout parser re-splits its whole buffer on every chunk, so a long JSON-RPC line costs O(n²) to receive: a 30 MB line takes about 3.8 s instead of 17 ms. Lines that size are real (#11216: Cursor tool results of ~30 MB, replayed on every resume).

Change

makeStrictNdJsonRpcParser scans only the new chunk for a newline and joins buffered fragments once, when a line completes. This is the same fix #8605 made for the Codex app-server.

-  buffer += decode(bytes)
-  lines = buffer.split("\n")
-  buffer = lines.pop()
+  chunk = decode(bytes)
+  lineFragments.push(chunk)
+  if chunk has no "\n"
+    return []
+  lines = lineFragments.join("").split("\n")
+  lineFragments = [lines.pop()]

Output is unchanged: same lines, same order, \r kept, malformed lines still go to the strict codec.

Scope and approval

A focused fix for an obvious defect (quadratic buffering) in one function, so it has no prior issue.

Verification

  • New tests in protocol.test.ts, modelled on fix(codex): avoid quadratic app-server input buffering #8605: a 4 MB notification in 1 KB chunks, plus framing at chunk sizes 1, 7 and 1024 over \r\n, split multibyte characters and an unfinished last line. 33/33 pass; package typecheck and lint are clean apart from a lint warning at line 649 that predates this change.
  • Fed the old and new parser the same chunk sequences, including empty chunks, string input, \r/\n split across chunks and 2,000 random splits: 0 differences in output.
  • Benchmark (Node 24.21, the real jsonRpc codec, median of 5):
Input 16 KB chunks: before → after 64 KB chunks: before → after
1 line, 4 MB 59 ms → 2.5 ms (24×) 16 ms → 2.1 ms (8×)
1 line, 16 MB 1,069 ms → 12.5 ms (86×) 277 ms → 11.2 ms (25×)
1 line, 30 MB 3,819 ms → 17.5 ms (219×) 883 ms → 17.1 ms (52×)
200k small lines (17 MB) 80.5 ms → 82.0 ms 81.7 ms → 81.0 ms
4 MB notification test (1 KB chunks) 800 ms → 19 ms —

Not checked: a live Cursor session. Open #19585 edits the same function, so whichever lands second needs a small rebase.

Written by Claude Opus 5.5 in Claude Code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@KiroshiAiviom @claude
perf(acp): long agent output lines are no longer re-split on every chunk
18a8dfc
The ACP stdout parser appended each chunk to one string buffer and re-split the
whole buffer, so a single long JSON-RPC line cost O(n^2) in its length. Cursor
can emit ~30 MB lines on every resume, which took seconds to frame.

Unfinished lines are now kept as fragments and only the new chunk is scanned
for a newline. The fragments are joined and split once when a line completes,
so small-line throughput is unchanged. Emitted lines, UTF-8 streaming, "\r\n"
handling and malformed-line behavior stay the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 14, 2026
macroscopeapp[bot]
macroscopeapp Bot approved these changes Oct 14, 2026
View reviewed changes
@macroscopeapp

macroscopeapp Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 18a8dfc

Macroscope's review found this PR approvable — This is a small, self-contained ACP parser performance fix that preserves existing NDJSON and UTF-8 behavior while avoiding repeated processing of long lines. Focused tests cover large fragmented output and framing edge cases, with no product-default or static-analysis configuration changes.

You can add or adjust custom eligibility rules. Learn more.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e8b81933-0ae3-4157-93b8-08440e0c929e
📥 Commits

Reviewing files that changed from the base of the PR and between 96b115d and e330a20.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 87239d36-5344-4c05-84a5-b1dd7a374663
📥 Commits

Reviewing files that changed from the base of the PR and between 348f217 and 18a8dfc.

📒 Files selected for processing: 2
  • packages/effect-acp/src/protocol.test.ts
  • packages/effect-acp/src/protocol.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The strict NDJSON parser now buffers input as fragments until a newline is available. New tests cover large fragmented messages, varied chunk sizes, line endings, and UTF-8 text across chunk boundaries.

Changes: NDJSON parsing

Layer / File(s) Summary
Fragment buffering and framing tests
packages/effect-acp/src/protocol.ts, packages/effect-acp/src/protocol.test.ts
The parser retains incomplete input as fragments and processes complete lines when a newline arrives. Tests cover a large notification and response, varied chunk sizes, CRLF/LF framing, and UTF-8 text across chunk boundaries.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 18a8d

No actionable merge-blocking issue remains; the change is ready for normal merge checks.

Pre-merge checks: Passed 4
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed No active directly linked issue remains. Issue #8605 is closed and supplies historical context only, so it adds no coding requirement. The reviewed changes in packages/effect-acp/src/protocol.ts and…
Out of Scope Changes check Passed The change stays within the stated scope. It updates makeStrictNdJsonRpcParser to retain fragments and adds focused tests for large fragmented input, framing, UTF-8, CRLF, and unfinished lines. Thes…
Title check Passed The title clearly describes the main performance fix: the ACP parser no longer re-splits long agent output lines on every chunk.
Description check Passed The description covers the problem, implementation, scope rationale, focused verification, benchmark results, limitations, and coordination with the overlapping pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

KiroshiAiviom added 2 commits October 15, 2026 14:28
@KiroshiAiviom
Merge branch 'main' into perf/acp-ndjson-framing
96b115d
@KiroshiAiviom
Merge branch 'main' into perf/acp-ndjson-framing
e330a20
@maria-rcks

maria-rcks commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Note

Written by claude-opus-5-5 on behalf of Maria

Thanks for this. I'm closing it as part of PR triage. Right now we're only taking focused bug fixes from outside contributors (see Read this first), and this PR is not one.

From the review: The ACP line-buffering optimization needs a performance measurement from a real agent session; synthetic codec benchmarks do not establish its impact on the user path.

If you think this was a mistake, message me on Twitter at @maria_rcks and I'll take another look.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@maria-rcks maria-rcks closed this Oct 17, 2026
@only21mil only21mil mentioned this pull request Nov 1, 2026
fix(acp): a blank line from an ACP agent no longer ends the session #28851
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@macroscopeapp macroscopeapp[bot] macroscopeapp[bot] approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@KiroshiAiviom @maria-rcks
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.