Repository navigation
perf(agents): cut process output into lines in linear time - #4217
LordMelkor wants to merge 3 commits into
Conversation
Co-authored-by: Jello <c9085e5557728e0eb4eba927ae283fb1f27e65319dfa77e2ee2125e2cba7042d@buzz.block.builderlab.xyz> Signed-off-by: LordMelkor <kray@squareup.com>
Co-authored-by: Jello <c9085e5557728e0eb4eba927ae283fb1f27e65319dfa77e2ee2125e2cba7042d@buzz.block.builderlab.xyz> Signed-off-by: LordMelkor <kray@squareup.com>
Co-authored-by: Jello <c9085e5557728e0eb4eba927ae283fb1f27e65319dfa77e2ee2125e2cba7042d@buzz.block.builderlab.xyz> Signed-off-by: LordMelkor <kray@squareup.com>
|
🤖 Closing this one. It does not clear the bar we hold every speed change to: about one second less waiting plus frozen time on something a person does in the app. Measured in the app (Linux desktop, WebKitGTK, debug build, real Goose agent, synthetic 8.4 MB session, three journeys per build, interleaved). The journey: open the Transcript tab, send one prompt, watch the turn until it shows Completed. Waiting plus frozen time is the open wait plus every frame of 100 ms or more.
That is 0.26 s on a journey of about 50 s. Pi and Codex opens did not change (table in the description). Not measured in the app: after an app restart a Goose turn runs in a new session, so the tab holds 10 rows at the end of this journey, and the journey never refreshes a long session that is still working. The Node numbers in the description (output callback 317–376 ms → 12–18 ms per refresh) cover that case and stand as measured in Node only. The change is correct and small (+9/−5 in core), but 0.26 s does not earn a maintainer's review. The branch stays in case a long live Goose or Pi session ever shows this cost in the app. |
A person opening an 8.4 MB Goose transcript waits 1.17 s on
main(down to 0.97 s here) and pays that read on every live refresh while the agent works (in Node, Goose's output callback drops from 317–376 ms to 12–18 ms, and a full refresh from 556–625 ms to 255–274 ms). Goose sends the whole session as one multi-MB line in 64 KiB pieces, and the line-splitting loop re-scanned the entire buffer on every piece; keeping the next line-end position checks an arriving piece only when no line end is buffered yet.Size: +25/−12 production in three files — +9/−5 in core (
acp/process.ts), +5/−1 in Pi (pi/pi.ts), and +11/−6 in Codex (codex/rpc.ts, which also resets the tracked position when reopening after an oversized line). Whole PR: +121/−12 with tests.Why core, and how small
acp/process.ts)The Pi and Codex changes are inside their bundled plugins.
Numbers
In the app — Linux desktop (WebKitGTK, no GPU, debug build), real Goose, Pi, and Codex agents, synthetic sessions, three opens per build (click to first rows):
mainRows match
mainon every open (459, 1,392, and 3,734 rows). Pi and Codex show no app-open speedup because their opens are dominated by one drawing frame (3.4 s on Pi, 2.0 s on Codex), which#4181addresses instead (Pi's 0.05 s difference sits inside that frame: 3.47–3.51 s vs 3.40–3.42 s, read 0.30 s vs 0.32 s).In Node — real goose-acp 1.60.1, Pi host, and isolated ACP loop
Three runs of 11–12 refreshes each on the same sessions (turns, rows, and characters match
mainat every refresh):mainCosts and what stays
Checks
c40797c012: Codex 765 passed, 4 skipped; Pi 253 passed, 4 skipped; ACP client 70 passed. Both type checks and the design lane pass; trial merge withmainis clean.landmineslint: 0 timing findings, 1 kept (shared fixture intests/beside other shared test helpers).End-to-end test (AGENTS.md step 3)
An end-to-end test by the maintainer's agent on a separate Linux machine, made with human guidance from the maintainer driving this work.
pnpm tauri build --debug --no-bundle, local relay, throwaway identity, real Goose, Pi, and Codex agents, synthetic sessions.main, time click to first rows, then send a live Goose prompt and watch the turn move from Working to Completed.cd5b2e622(one commit before head; the final commit touches Codex files only), and Codex ran at head.New tests
One shared fixture cuts a reply at every position, one character at a time, with CRLF, blank lines, padding, and an unfinished record, feeding it through the real ACP client, Pi host, and Codex client. Output must match for every cut; four single off-by-one mutations each break a case.
🤖 Generated with Claude Code