GeezerVison is showing github.com — perf(server): streamed writes no longer re-parse their payload by EmanuelMedinaAraujo · Pull Request #25162 · pingdotgg/t3code
Conversation
Problem
Every streamed update writes message.updated and turn-item.updated through ProjectionStoreV2.apply. Both cases encode the payload to JSON, then JSON.parse the whole thing again, full streamed reply included, only to read createdAt/updatedAt back out. The extra parse runs on the event loop inside the write transaction, and its cost grows with reply length on every chunk.
Fixes #25157
Change
Encode the two timestamps directly from event.payload with Schema.DateTimeUtcFromString, the same schema the payload uses, so the indexed columns get identical strings without the parse. Only these two cases change; other projection cases still parse their small payloads.
Scope and approval
This is a small, focused fix with no behavior change: the stored columns and payload stay byte-identical. The bug is described in #25157.
Verification
- New test
indexes streamed messages and turn items by the timestamps in their payloads checks that created_at/updated_at columns equal the timestamps inside payload_json for a ~3 KB streamed message and turn item, including millisecond precision.
vp test run apps/server/src/orchestration-v2/ProjectionStore.test.ts: 47 passed. vp fmt --check, vp lint and the server typecheck are clean.
- Benchmark on file-backed SQLite (
SqlitePersistence.layerFromPath), Linux, Node 26.12.1. Each figure is the median of 200 message.updated + turn-item.updated writes of one reply, from two separate runs:
| Reply size |
main |
this PR |
| 10 KB |
0.92 / 0.92 ms |
0.38 / 0.44 ms |
| 100 KB |
1.16 / 1.15 ms |
0.96 / 0.99 ms |
| 500 KB |
4.43 / 4.38 ms |
3.40 / 3.43 ms |
I did not measure this through a live provider stream.
Written by Opus 5.5 (high) in T3 Code (Claude Code harness) on behalf of Emanuel.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Projection writes for message.updated and turn-item.updated parsed the
payload they had just encoded, full streamed text included, only to read
its timestamps. They now encode the timestamps directly with the schema
the payload uses.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Approvability
Verdict: Approved at 36b2517
Macroscope's review found this PR approvable — This is a narrowly scoped server performance fix: timestamp columns are encoded without reparsing large streamed payloads, and live websocket events avoid a redundant wire projection already performed upstream. Added tests verify timestamp consistency and single-projection behavior, with no product-default or static-analysis configuration changes.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Oct 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 2eccc57 and c1dfb3f.
Files selected for processing: 2
-
apps/server/src/orchestration-v2/ProjectionStore.test.ts
apps/server/src/orchestration-v2/ProjectionStore.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
-
ProjectionStore now encodes message and turn-item timestamps directly from event payload fields instead of parsing encoded payload JSON. A SQL test checks that the indexed timestamps match the payload timestamps.
Changes: Timestamp indexing
| Layer / File(s) |
Summary |
Encode payload timestamps for SQL writes apps/server/src/orchestration-v2/ProjectionStore.ts, apps/server/src/orchestration-v2/ProjectionStore.test.ts |
Message and turn-item writes encode timestamps from payload fields. The SQL test checks stored timestamp columns against the payload values. |
Priority: Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Refactor
Possibly related PRs
- pingdotgg/t3code#24145: Both PRs change the
message.updated and turn-item.updated SQL handlers in ProjectionStore; this PR avoids parsing payload JSON, while that PR skips updates when indexed fields are unchanged.
Suggested reviewers: t3dotgg
Merge Risk: Minimal · up to c1dfb
-
No actionable merge-blocking risk remains.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title is concise, specific, and accurately summarizes the main performance change: streamed writes no longer re-parse their payload. |
| Description check |
 |
The description includes all required sections. It explains the problem, implementation, scope, approval basis, focused verification, benchmark results, and unmeasured live-stream coverage. |
| Linked Issues check |
 |
For #25157, ProjectionStore.ts now encodes event.payload.createdAt and event.payload.updatedAt with Schema.DateTimeUtcFromString in the message.updated case. It encodes `event.payload.update… |
| Out of Scope Changes check |
 |
The changes stay within #25157. The production diff changes only timestamp encoding in the two specified projection cases. The added test directly verifies the required indexed values for streamed mes… |
Full details: Linked Issues check
-
Explanation
For #25157, ProjectionStore.ts now encodes event.payload.createdAt and event.payload.updatedAt with Schema.DateTimeUtcFromString in the message.updated case. It encodes event.payload.updatedAt the same way in the turn-item.updated case. These cases no longer call parseEncodedPayload to read timestamps. The new test verifies indexed timestamp values against payload_json, including millisecond precision and streamed text. The separate ws.ts concern is not required by #25157.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within #25157. The production diff changes only timestamp encoding in the two specified projection cases. The added test directly verifies the required indexed values for streamed messages and turn items. No unrelated production behavior is changed.
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Oct 27, 2026
|
Thank you, @EmanuelMedinaAraujo, for finding and fixing this first. https://git.cafe/pingdotgg/t3code/pulls/25252 makes the same change (encode createdAt/updatedAt straight from the typed payload instead of re-parsing the JSON) in the same two files, and adds a regression test that fails on main plus a live-server run, so we're taking that one forward and closing this as a duplicate. Your write-up of where the parse sits inside the write transaction, and the file-backed SQLite benchmark, were the clearest description of the cost.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Milestone
No milestone
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.
|