GeezerVison is showing github.com — perf(server): fork threads load faster when local turns fill the first page by juliusmarminge · Pull Request #20104 · pingdotgg/t3code
Conversation
Opening a fork whose own turns fill the first page still loaded and decoded inherited tool output that the bounded response discarded. This counts the parent's retained rows instead, preserving item positions and history cursors.
The payload read and count share the same retained-row query. The optimization applies only to an initial, unanchored read whose local user turns fill the page and whose parent is not itself a run fork. Partial pages, nested forks and anchored history retain the recursive read.
Fixes #18915. Original work by @bompus in #18071, continued on this maintainer-owned PR.
Verification
- One regression in the existing
ProjectionStore.test.ts covers partial, filled and nested forks; the PR's added test code is reduced from 176 to 156 lines. All 43 tests from main are unchanged (44 total before and after takeover).
- Before: the new regression against current main's implementation gives 43 passed / 1 failed, detecting parent payload parsing. After restoration: 44 passed.
ProjectionStore.test.ts, threadHistoryPaging.test.ts and ThreadStream.test.ts: 82 passed. Touched-file lint and formatting pass.
- Server
tsc-rs --noEmit -p apps/server/tsconfig.json: passed (Effect suggestions only).
- One full-diff adversarial review round by Claude Opus 5.5 and GPT-6-Sol: no blockers. The optional suggestion to split the count-only helper was declined because the shared path already keeps the change small.
Performance proof
Measured the actual in-process HTTP bounded-snapshot handler with SQLite and synthetic data: 14 parent turns and 14 fork turns, with two 64 KiB command outputs per turn. Three paired runs used 20 warmups and 60 requests per implementation. Every compared response body was identical, including cursors.
| Metric |
Main |
This PR |
| Median request time |
18.56 ms |
12.37 ms |
| Median CPU time per request |
19.78 ms |
13.25 ms |
| Parent payload bodies parsed per request |
24 |
0 |
About 33% less time and CPU in this fixture. Benchmark script · Full output. This is server work with synthetic data; no screenshots apply. Network latency, production data and client rendering were not measured.
Not verified on macOS, Windows, iOS, Android or Electron desktop.
Takeover tests: GPT-6-Astra (high); implementation: GPT-6.1-Sol (high), through the Codex harness in T3 Code. Adversarial review: Claude Opus 5.5 through Claude Code and GPT-6-Sol through Codex.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Replace the PR's fork cursor test with one that compares the bounded
snapshot of a fork against the full projection. With nine local turns the
page still includes inherited parent rows and reads their bodies; with ten
it skips them, and positions, the fork marker, cursor and hasMoreHistory
still match the full read.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t page
After #17387 an initial bounded snapshot of a forked thread still read and
decoded its parent's retained turn items, including large tool outputs,
even when the fork's own user turns filled the returned page. Those
inherited rows are dropped during bounding; only their count sets the
positions and the history cursor.
Share the window selection between the payload read and a count, and when
local turns fill the page count the parent's retained rows in SQL instead
of reading their bodies. The count query returns NULL for a parent that is
itself a run fork, which keeps the full ancestry read for nested forks.
Closes #18915
Co-Authored-By: Claude Fable 5.1 <[email protected]>
A fork of a fork inherits the grandparent's rows through its parent, so
counting only the parent's own rows would misplace the page. Add the
nested case to the filled fork page test; it fails when the count query
stops excluding run-forked parents.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Approvability
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — This production optimization adds an automatic fast path that skips recursive ancestor payload reads when a fork’s local turns fill the first page, while reconstructing positions and cursors from a SQL count. The behavior is narrowly tested, but the data-dependent suppression of existing processing warrants human review.
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.
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
| Provider |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
Total thread wire |
5.0 KiB |
5.0 KiB |
+7 B (+0.1%) |
6.8 KiB |
✅ |
| Codex |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Codex |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
+7 B (+0.6%) |
2.0 KiB |
✅ |
| Codex |
Live turn WebSocket decoded |
20.9 KiB |
20.9 KiB |
0 B (0.0%) |
29.3 KiB |
✅ |
| Codex |
Live turn messages |
2 |
2 |
0 (0.0%) |
8 |
✅ |
| Claude |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Claude |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Claude |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Claude |
Live turn WebSocket decoded |
21.2 KiB |
21.2 KiB |
0 B (0.0%) |
29.3 KiB |
✅ |
| Claude |
Live turn messages |
2 |
2 |
0 (0.0%) |
8 |
✅ |
Baseline: 293938b · PR result: a39bb76 · Source CI: success
Scenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Oct 16, 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
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
cb5bfb87-f8e6-424b-a853-3a2db7ca9796
📥 Commits
-
Reviewing files that changed from the base of the PR and between b2e4549 and a39bb76.
📒 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; 0 remain after this review.
📝 Walkthrough
-
Bounded fork snapshots now count retained parent rows instead of decoding parent payloads when local turns fill the page. The count offsets local item positions. Tests cover partial pages, full pages, and nested forks.
Changes: Fork snapshot paging
| Layer / File(s) |
Summary |
Retained-window selection apps/server/src/orchestration-v2/ProjectionStore.ts |
A shared query selects retained rows for bounded projection reads and inherited-row counting. |
Fork row counting and positions apps/server/src/orchestration-v2/ProjectionStore.ts, apps/server/src/orchestration-v2/ProjectionStore.test.ts |
Eligible fork reads count retained source rows and use the count to position visible items. Tests compare bounded results with full snapshots across partial pages, full pages, and nested forks. |
Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor · Severity of issue fixed: Low
Suggested reviewers: t3dotgg
Merge Risk: ⚪ Minimal · up to a39bb
-
The fork paging optimization is mergeable after normal checks; no confirmed behavior regression remains.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title clearly and concisely describes the primary performance improvement for fork threads whose local turns fill the first page. |
| Description check |
 |
The description explains the problem, implementation scope, linked issue, verification results, performance evidence, and unverified environments. It is mostly complete, although it does not use every… |
| Linked Issues check |
 |
Issue [#18915] requires the filled, initial, unanchored fork page to avoid decoding discarded inherited tool-output payloads. ProjectionStore.ts reuses the retained-row SQL selection for an inherite… |
| Out of Scope Changes check |
 |
The changes stay within issue [#18915]. They refactor the retained-row query, add inherited-row position handling, add the eligible count-only path, and add focused projection tests. These changes sup… |
Full details: Description check
-
Explanation
The description explains the problem, implementation scope, linked issue, verification results, performance evidence, and unverified environments. It is mostly complete, although it does not use every template heading and does not include an explicit maintainer approval comment.
Full details: Linked Issues check
-
Explanation
Issue [#18915] requires the filled, initial, unanchored fork page to avoid decoding discarded inherited tool-output payloads. ProjectionStore.ts reuses the retained-row SQL selection for an inherited count and builds visible rows with the inherited offset. The recursive path remains for partial pages, anchored reads, nested forks, and run-forked parents. The added regression covers partial, filled, and nested forks, plus bounded output and cursor behavior.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within issue [#18915]. They refactor the retained-row query, add inherited-row position handling, add the eligible count-only path, and add focused projection tests. These changes support the requested server optimization and its behavior guarantees. No unrelated product changes are shown.
✨ Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- 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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Taking over this one: merging current main, re-cutting the test to the minimum, and re-reviewing before it lands.
|
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.
Uh oh!
There was an error while loading. Please reload this page.
Labels
macroscope-review
Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews
size:L
100-499 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or 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.
|