Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf: large threads open from a viewport snapshot, and typing and streaming render less #18220

Closedmaria-rckswants to merge 244 commits intot3/perf-wave2 fromt3/perf-wave3opened View on GitHub

maria-rckscommented

stacked on #18219. this diff shows only this layer.

recorded largest-thread opening: wave 2 above and wave 3 below

threads open from a viewport snapshot and fetch older history as needed. streamed text updates its own row, typing stays local to the editor, and unchanged timeline entries are reused. server activity updates patch sqlite fields and subscribers share encoded events; independent config discovery runs concurrently.

historical medians of five interleaved linux/chromium runs, 0db57d88ed → 1634ef4314, before trimming:

metricbeforeafter
largest thread cold open, paint927 ms371 ms
streamed reply, main-thread work per batch20.7 ms6.08 ms
empty composer, script per key6.28 ms3.11 ms

the later trim-only recheck measured largest-thread paint at 349.5 → 322 ms, with overlapping ranges. the historical table is not a fresh measurement of the integrated head.

model: claude-opus-5-5 coordinating gpt-6.1-sol subagents, harness: claude code in t3 code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—4.9 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.8 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.8 KiB—29.3 KiB✅
      CodexLive turn messages—1—8✅
      ClaudeTotal thread wire—5.0 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.8 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—21.2 KiB—29.3 KiB✅
      ClaudeLive turn messages—2—8✅

      Baseline: unavailable · PR result: 7f2c3cf · 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.

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — This XXL PR changes the default thread-opening path and introduces cross-layer snapshot hydration, streaming, composer, sidebar, persistence, startup, and RPC behavior across 99 files. It also adds static-analysis suppressions and has an unresolved Medium finding about potentially unbounded checkpoint lists in viewport snapshots, leaving material risk for human review.

      Needs human approval because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity

      No code changes detected at 7f2c3cf. Prior analysis still applies.

      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. @@ -3343,5 +3401,20 @@
      33433401 WHERE thread_id = ${threadId}
      33443402 AND (status IN ('pending','capturing')
      33453403 OR checkpoint_id IN (SELECT value FROM json_each(${cohortCheckpointIds}))
      33463404 OR run_id IN (SELECT value FROM json_each(${cohortRunIds}))
      3347- OR node_id IN (SELECT value FROM json_each(${cohortNodeIds})))
      3405+ OR node_id IN (SELECT value FROM json_each(${checkpointNodeIds}))
      3406+ -- A viewport keeps the runs of the latest user turns listed for
      3407+ -- the Diff panel and Review, bounded like a turn-aligned window:
      3408+ -- from the run of the twelfth latest user turn (a page plus
      3409+ -- two), or every run when there are fewer. Wake-up runs ride
      3410+ -- along without using up the turn budget. With no user turn
      3411+ -- among the latest turns, only the window's own runs are listed.
      3412+ -- Their file lists arrive with the rows' history page.
      3413+ OR (${window.deferHistoricalSupport ? 1 : 0} = 1 AND app_run_ordinal >= (
      3414+ WITH turn_starts AS (
      3415+ SELECT run.ordinal AS run_ordinal,
      3416+ json_extract(item.payload_json, '$.createdBy') = 'user' AS by_user
      3417+ FROM orchestration_v2_projection_turn_items AS item
      3418+ JOIN orchestration_v2_projection_runs AS run ON run.run_id = item.run_id
      3419+ WHERE item.thread_id = ${threadId}
      3420+ AND item.type = 'user_message'
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium orchestration-v2/ProjectionStore.ts:3420

      A viewport with one old user turn followed by many notification-driven wake runs includes every historical checkpoint, producing an unbounded checkpoint list. turn_starts filters to user_message rows, so those notification-started runs do not fill the raw-turn budget and the computed cutoff remains 0; include notification-started runs in this budget, as the timeline's run_starts does.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/server/src/orchestration-v2/ProjectionStore.ts around line 3420:
      
      A viewport with one old user turn followed by many notification-driven wake runs includes every historical checkpoint, producing an unbounded checkpoint list. `turn_starts` filters to `user_message` rows, so those notification-started runs do not fill the raw-turn budget and the computed cutoff remains `0`; include notification-started runs in this budget, as the timeline's `run_starts` does.
    6. Taking over this one for terminal-preview-24. I’m rebuilding the remaining viewport snapshot and history hydration work from current main as a smaller stack, preserving the rendering improvements already on main. I’ll keep this PR open until the replacement has current-head tests, adversarial review, and Linux web evidence, and credit the original work in the replacement.

    7. juliusmarminge assignedjuliusmarminge

    8. Thanks @maria-rcks — the viewport-first snapshot and on-demand history work identified the remaining large-thread transfer problem and provided the basis for this rebuild.

      Replaced by a smaller stack built against current main:

      • #21475: optional server viewport snapshots, prompt/control retention, deferred checkpoint files and thread-scoped history support.
      • #21476: client opt-in, safe history/checkpoint hydration, cache upgrade/rollback, mobile file counts, paged prompt recall and Edit from here.

      I compared the original 99-file diff against the replacement. The snapshot/history behavior is covered by the two layers above. Sidebar, editor, settings, bootstrap, persistence and native cleanup changes were omitted because current main has the related rendering/persistence work and those concerns do not belong in this focused replacement. This does not claim additional typing, streaming or paint latency improvements.

      The rebuild is 30 files, with all 374 focused tests passing and scoped lint/typechecks passing. Five fresh whole-stack review rounds fixed fork control leaks, boundary prompts, indexed reads, paged recall/rewind and prompt/checkpoint byte accounting; both final reviewers found no confirmed code blockers. Published Linux web proof shows 3,694,234 → 58,369 bytes on a disposable 5,002-row thread, and restores all 4,927 omitted rows on demand. Before/after images and a functional paging recording are embedded in the client PR.

      Both published heads pass build, lint, tests and CodeRabbit. The complete current-head refresh found no unresolved review threads or active change requests; human approvability remains outstanding.

      Closing this original as replaced, preserving author credit in both PRs. The stack remains unmerged and still requires human approval. Native macOS, Windows, Electron, iOS and Android runtime verification, remote/relay/tunnel flows and real provider rollback were not exercised here; the replacement bodies state those limits.

    9. juliusmarminge closed this

Sign in to join this conversation.