Skip to content

perf(server): streamed writes stop re-parsing their payload on the main thread - #118

Merged
fireboltdude1357 merged 2 commits into
patch/streamed-write-timestampsfrom
fix/carry-25162
Oct 27, 2026
Merged

fireboltdude1357 merged 2 commits into
patch/streamed-write-timestampsfrom
fix/carry-25162

Conversation

@fireboltdude1357

Copy link
Copy Markdown
Owner

While agents stream, every message and turn-item write re-parsed its whole JSON payload on T3's main thread just to read back two timestamps. That's main-thread time taken from every other request. This carries upstream pingdotgg#25162, which encodes those timestamps directly instead.

It's merged onto upstream 0b0417a without conflicts, and its diff is identical to upstream's (git patch-id). Upstream's CI never ran on it, and its author is unvouched, so it was reviewed line by line:

  • Scope. It changes two files: ProjectionStore.ts (+5/−5, a new encodePayloadTimestamp and three call sites) and one test. There are no network, process or file calls, no dependency or lockfile changes, no dynamic code and no auth changes.
  • Stored bytes. They don't change. payload_json is the same encoder output as before. The created_at and updated_at columns are now written with Schema.DateTimeUtcFromString, the same codec the payload schemas use for those fields, and none of the 24 turn-item members overrides it.

Evidence. The PR's own test asserts that the indexed timestamps equal the ones in the payload. It passes with and without the change, because this is a pure performance change. A timing harness checked the mechanism instead: 300 streamed write pairs with about 215 KB of text each, 3 runs per side.

Bytes through JSON.parse Wall time
Before 132.2 MB 525 to 562 ms
After 0 435 to 821 ms

The re-parse is gone. Wall time is within noise at this size, so treat it as a CPU and GC saving.

Review tier: 6/10; how two indexed timestamp columns are written

Two-way door: removing the patch line drops it from the next fork build

Blast radius: created_at and updated_at on stored messages and turn items

Changes made by Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

EmanuelMedinaAraujo and others added 2 commits October 26, 2026 01:00
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 <noreply@anthropic.com>

@fireboltdude1357 fireboltdude1357 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual review round 1: crev (claude-opus-5-5 + gpt-6.1-sol) (tier 7/10, deep review)

No verified findings.

Reviewed 2 files (+105 -5), 0b0417a5..67c3161e against origin/patch/streamed-write-timestamps.

Tier 7/10 from claude-opus-5-5: Changes how persisted created_at/updated_at index columns are written for every streamed message and turn item; a format mismatch would silently corrupt ordering and pagination data.

Complexity low: Small local swap of three call sites to encode timestamps directly instead of re-parsing payload JSON; the only subtlety is matching the codec to the payload schema.

@fireboltdude1357
fireboltdude1357 merged commit c33a79c into patch/streamed-write-timestamps Oct 27, 2026
1 check passed
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.

2 participants