Repository navigation
perf(server): streamed events no longer rewrite the whole thread row - #18890
Conversation
Every run, node, provider-turn and turn-item event read the thread's projection row, decoded it, re-encoded it and wrote it back just to move updatedAt. During a streamed turn that is dozens of decode/encode cycles a second. The timestamp is now patched in place with json_set, the same way run.background-work-cancelled already patches a single run field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a localized server performance change that preserves thread activity timestamps while avoiding full payload rewrites during streaming. The accompanying test verifies unchanged thread data, shell consistency, and the reduced SQL access pattern. Notes:
You can add or adjust custom eligibility rules. Learn more. |
…(adopts upstream pingdotgg#18890) Own diff of pingdotgg#18890 at f544d9a, applied on stark/main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Numbers from a busy install, to put a size on what this saves. We adopted the change into a fork today (Windows 11); the figures are read-only queries on that server's
So the typical row is small, but the threads that produce most events are the ones with the largest rows. Multiplying each thread's non- On our branch Not measured yet: the effect on write time or event-loop delay after the change. This server logs event loop stalls of 2 to 7 seconds a few times an hour; I will look at whether that changes once it runs this build, and say so here only if there is a clear difference. Posted by Claude (Opus 5.5, Claude Code via T3 Code) on behalf of @AdEx-Partners-DE. |
Dismissing prior approval to re-evaluate f544d9a
Sync 1014a: 22 upstream commits, including pingdotgg#17561 (full-screen visual replies), pingdotgg#19226 and pingdotgg#18890 (server perf), and pingdotgg#19213 (Effect 4.0.4). The fork html-render panel card keeps its slot in MessagesTimeline and its narrow-layout fallback takes upstream's full-screen callback in place of the removed onOpen. SessionMcpService calls randomUUIDv4() as Effect 4.0.4 requires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
## What's Changed * chore(deps): Effect 4.0.4 and OpenCode 2.0.28, dropping the patches they made unnecessary by @juliusmarminge in pingdotgg/t3code#19213 * fix(server): a Claude 403 no longer tells you to log in again by @shivamhwp in pingdotgg/t3code#15872 * fix(server): persist only changed pull request links by @juliusmarminge in pingdotgg/t3code#19248 * fix(server): delegate_task explains that supervised runtime modes pause the child by @saphid in pingdotgg/t3code#14416 * fix(server): Claude subagent progress no longer re-stores the unchanged prompt by @Gigioxx in pingdotgg/t3code#18375 * fix(server): thread list reads no longer freeze the server on large databases by @t3dotgg in pingdotgg/t3code#19226 * perf(server): streamed events no longer rewrite the whole thread row by @Baker-Harrison in pingdotgg/t3code#18890 * docs: close PRs written by Gemini or Muse Wonder by @t3dotgg in pingdotgg/t3code#19286 * fix: update all no longer runs agents twice or loses background work by @t3dotgg in pingdotgg/t3code#19291 * fix(server): enforce one database owner and guard update rollback by @maria-rcks in pingdotgg/t3code#16102 * perf(server): reuse stored turn item positions by @tannerpolley in pingdotgg/t3code#19230 * perf(server): avoid quadratic resource history replay by @saphid in pingdotgg/t3code#18825 * fix(server): repair ownership UUID generation by @t3dotgg in pingdotgg/t3code#19298 * fix(client-runtime): slow config snapshots no longer drop working connections by @saphid in pingdotgg/t3code#14518 * fix(server): bound activity publishes so stalled responses release the worker by @saphid in pingdotgg/t3code#18830 * perf(shared): cached SQLite statements no longer hold large parameters by @t3dotgg in pingdotgg/t3code#19305 * fix(provider-cursor): Cursor text generation no longer leaks SQLite file handles on every call by @t3dotgg in pingdotgg/t3code#19310 * fix(server): make SQLite checkpoints durable on macOS by @t3dotgg in pingdotgg/t3code#19304 * perf(server): Codex plan streaming no longer commits every token by @t3dotgg in pingdotgg/t3code#19317 * fix(server): large file edits no longer store their full diff twice by @t3dotgg in pingdotgg/t3code#19316 * fix(web): settings save again after a stored value fails decode by @t3dotgg in pingdotgg/t3code#19312 * fix(server): HTML and Markdown attachments no longer fail OpenCode turns by @t3dotgg in pingdotgg/t3code#19319 * fix(server): worktree paths no longer vanish on git before 2.36 by @t3dotgg in pingdotgg/t3code#19315 * fix(acp): custom models now reach the agent instead of failing to open by @t3dotgg in pingdotgg/t3code#19313 * fix(server): Claude no longer shows unavailable when its health check can't run in $HOME by @t3dotgg in pingdotgg/t3code#19320 * fix(server): stalled OAuth token requests no longer block credential calls by @t3dotgg in pingdotgg/t3code#19321 * fix(server): steered Claude turns no longer undercount token usage by @t3dotgg in pingdotgg/t3code#19314 * fix(server): closing a Claude session no longer leaves plugin MCP servers running by @t3dotgg in pingdotgg/t3code#19322 * fix(client-runtime): T3 Connect link timeouts explain the relay 504 by @t3dotgg in pingdotgg/t3code#19329 * fix(web): settle shortcut moves to the next thread like the sidebar by @t3dotgg in pingdotgg/t3code#19328 * fix(acp): Copilot's default agent no longer disappears from the Agent menu by @t3dotgg in pingdotgg/t3code#19330 * perf(server): SQLite checkpoints no longer block the event loop by @t3dotgg in pingdotgg/t3code#19324 * fix(mobile): incompatible environments now say whether to update the app or the host by @t3dotgg in pingdotgg/t3code#19331 * fix(web): live reasoning stays scrolled to the newest text while it streams by @t3dotgg in pingdotgg/t3code#19334 * fix(server): T3 Connect no longer stays down after a network change by @t3dotgg in pingdotgg/t3code#19335 * fix(clients): host images say when the connection lacks file access by @t3dotgg in pingdotgg/t3code#19337 * fix(clients): a resumed subagent no longer moves the later turn's Worked for row by @t3dotgg in pingdotgg/t3code#19338 * fix: Claude and Codex no longer time out behind mise wrappers by @t3dotgg in pingdotgg/t3code#19340 * perf(server): turns no longer re-read merged PRs from GitHub by @t3dotgg in pingdotgg/t3code#19344 * docs(settings): explain that provider update checks also gate the model catalog by @fixfon in pingdotgg/t3code#18208 * fix(web): an unsaved citation comment survives a question or approval by @t3dotgg in pingdotgg/t3code#19350 * fix(server): changing Claude effort no longer fails while background agents run by @t3dotgg in pingdotgg/t3code#19341 * fix(server): service updates no longer fail on full disks or large databases by @t3dotgg in pingdotgg/t3code#19311 ## New Contributors * @Baker-Harrison made their first contribution in pingdotgg/t3code#18890 * @tannerpolley made their first contribution in pingdotgg/t3code#19230 **Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261014.3093...v0.0.46-nightly.20261014.3105 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261014.3105
## What's Changed * chore(deps): Effect 4.0.4 and OpenCode 2.0.28, dropping the patches they made unnecessary by @juliusmarminge in pingdotgg/t3code#19213 * fix(server): a Claude 403 no longer tells you to log in again by @shivamhwp in pingdotgg/t3code#15872 * fix(server): persist only changed pull request links by @juliusmarminge in pingdotgg/t3code#19248 * fix(server): delegate_task explains that supervised runtime modes pause the child by @saphid in pingdotgg/t3code#14416 * fix(server): Claude subagent progress no longer re-stores the unchanged prompt by @Gigioxx in pingdotgg/t3code#18375 * fix(server): thread list reads no longer freeze the server on large databases by @t3dotgg in pingdotgg/t3code#19226 * perf(server): streamed events no longer rewrite the whole thread row by @Baker-Harrison in pingdotgg/t3code#18890 * docs: close PRs written by Gemini or Muse Wonder by @t3dotgg in pingdotgg/t3code#19286 * fix: update all no longer runs agents twice or loses background work by @t3dotgg in pingdotgg/t3code#19291 * fix(server): enforce one database owner and guard update rollback by @maria-rcks in pingdotgg/t3code#16102 * perf(server): reuse stored turn item positions by @tannerpolley in pingdotgg/t3code#19230 * perf(server): avoid quadratic resource history replay by @saphid in pingdotgg/t3code#18825 * fix(server): repair ownership UUID generation by @t3dotgg in pingdotgg/t3code#19298 * fix(client-runtime): slow config snapshots no longer drop working connections by @saphid in pingdotgg/t3code#14518 * fix(server): bound activity publishes so stalled responses release the worker by @saphid in pingdotgg/t3code#18830 * perf(shared): cached SQLite statements no longer hold large parameters by @t3dotgg in pingdotgg/t3code#19305 * fix(provider-cursor): Cursor text generation no longer leaks SQLite file handles on every call by @t3dotgg in pingdotgg/t3code#19310 * fix(server): make SQLite checkpoints durable on macOS by @t3dotgg in pingdotgg/t3code#19304 * perf(server): Codex plan streaming no longer commits every token by @t3dotgg in pingdotgg/t3code#19317 * fix(server): large file edits no longer store their full diff twice by @t3dotgg in pingdotgg/t3code#19316 * fix(web): settings save again after a stored value fails decode by @t3dotgg in pingdotgg/t3code#19312 * fix(server): HTML and Markdown attachments no longer fail OpenCode turns by @t3dotgg in pingdotgg/t3code#19319 * fix(server): worktree paths no longer vanish on git before 2.36 by @t3dotgg in pingdotgg/t3code#19315 * fix(acp): custom models now reach the agent instead of failing to open by @t3dotgg in pingdotgg/t3code#19313 * fix(server): Claude no longer shows unavailable when its health check can't run in $HOME by @t3dotgg in pingdotgg/t3code#19320 * fix(server): stalled OAuth token requests no longer block credential calls by @t3dotgg in pingdotgg/t3code#19321 * fix(server): steered Claude turns no longer undercount token usage by @t3dotgg in pingdotgg/t3code#19314 * fix(server): closing a Claude session no longer leaves plugin MCP servers running by @t3dotgg in pingdotgg/t3code#19322 * fix(client-runtime): T3 Connect link timeouts explain the relay 504 by @t3dotgg in pingdotgg/t3code#19329 * fix(web): settle shortcut moves to the next thread like the sidebar by @t3dotgg in pingdotgg/t3code#19328 * fix(acp): Copilot's default agent no longer disappears from the Agent menu by @t3dotgg in pingdotgg/t3code#19330 * perf(server): SQLite checkpoints no longer block the event loop by @t3dotgg in pingdotgg/t3code#19324 * fix(mobile): incompatible environments now say whether to update the app or the host by @t3dotgg in pingdotgg/t3code#19331 * fix(web): live reasoning stays scrolled to the newest text while it streams by @t3dotgg in pingdotgg/t3code#19334 * fix(server): T3 Connect no longer stays down after a network change by @t3dotgg in pingdotgg/t3code#19335 * fix(clients): host images say when the connection lacks file access by @t3dotgg in pingdotgg/t3code#19337 * fix(clients): a resumed subagent no longer moves the later turn's Worked for row by @t3dotgg in pingdotgg/t3code#19338 * fix: Claude and Codex no longer time out behind mise wrappers by @t3dotgg in pingdotgg/t3code#19340 * perf(server): turns no longer re-read merged PRs from GitHub by @t3dotgg in pingdotgg/t3code#19344 * docs(settings): explain that provider update checks also gate the model catalog by @fixfon in pingdotgg/t3code#18208 * fix(web): an unsaved citation comment survives a question or approval by @t3dotgg in pingdotgg/t3code#19350 * fix(server): changing Claude effort no longer fails while background agents run by @t3dotgg in pingdotgg/t3code#19341 * fix(server): service updates no longer fail on full disks or large databases by @t3dotgg in pingdotgg/t3code#19311 ## New Contributors * @Baker-Harrison made their first contribution in pingdotgg/t3code#18890 * @tannerpolley made their first contribution in pingdotgg/t3code#19230 **Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261014.3093...v0.0.46-nightly.20261014.3105 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261014.3105
Every streamed run, node and turn-item event bumped the thread's activity timestamp by selecting the thread projection row, decoding the full payload, re-encoding it and writing it back, on the hot path of every agent stream. Those pure timestamp bumps now patch the row in place with a single UPDATE that sets the updated_at column and json_set()s payload_json.$.updatedAt to the schema-encoded timestamp. A missing row stays a no-op. The thread.model-reported path, which also changes the model selection, keeps the full decode/encode. Ported from pingdotgg/t3code#18890. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Problem
ProjectionStoreV2.applyends with a step that runs for every event that is not athread.*event. It selects the thread's projection row, schema-decodes the payload, setsupdatedAt, schema-encodes it and writes the whole row back. Run, node, provider-turn and turn-item events all take that path, so a streamed turn pays a full decode and encode of the thread row for every flushed update, only to move one timestamp.Change
The timestamp is patched in place with one statement:
The value is encoded with the thread schema's own
updatedAtcodec, so what is stored is the same string as before. This is the idiomrun.background-work-cancelledalready uses to patch a single run field.thread.*events still write the full row.One side effect goes away: the old round trip also rewrote an older-shaped payload into the current encoded shape whenever any event touched the thread. That now happens only on
thread.*events. Readers decode through the same schema either way, and the SQL that reads thread payload fields directly (archivedAt,settledOverride,snoozedUntil,pullRequests, and so on) usesIS NULLorjson_array_length(...) > 0checks that treat an absent field like a null or empty one.Scope and approval
There is no linked issue or discussion. I am submitting this as a focused performance change with no intended change to behavior: the thread's
updatedAtand the rest of its payload read back the same as before. If you would rather see an issue first, I will open one.Verification
New test,
dates thread activity by a run event and leaves the rest of the thread alone, inProjectionStore.test.ts. It appliesthread.createdand then arun.createdfive seconds later, and asserts that:updatedAtmoved to the run event's time,updatedAt,SELECTagainstorchestration_v2_projection_threads.It fails on
main(expected [ Array(1) ] to be empty) and passes on this branch.Also run, in
apps/server:vp test run src/orchestration-v2/ProjectionStore.test.ts: 35 passed.vp test run src/orchestration-v2/runtimeLayer.test.ts src/orchestration-v2/ThreadManagementService.test.ts: 109 passed.vp run typecheck: passes.vp linton the changed files: no errors.Timing, from a scratch test that is not part of this PR: applying 5,000
turn-item.updatedevents to one thread through the test SQLite layer, three rounds each.mainat e24ea1dThat is about a third less time per applied event in this setup. It is one run on one machine, so read it as a direction, not a benchmark.
Not checked: a real on-disk database, or a running server during a live turn.
Environment: macOS, Node 26.7.0 (the repo asks for ^24.13.1; the install warned and everything ran).
Model and harness: Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code