Repository navigation
fix(server): older history no longer reads every attempt row to find steered ones - #41620
Conversation
…steered ones Opening a thread's older history looked up its superseded attempts with a query that could only use the (thread_id, run_id) index, so it read every attempt row of the thread. A partial index on superseded attempts makes it read only those. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Opening the older history of a long thread was slow when the database was not cached in memory: finding the thread's few superseded (steered) attempts meant reading every attempt row of the thread. A new migration adds a partial index on superseded attempts, so that lookup reads only those rows. The first older-history page from a cold cache loads about 25% faster.
Fixes #41587
Reproduction on main
Commit: origin/main 7f0e736 (also on the leased Windows checkout). Scripts are the reporter's own (platform-repro.mjs, coordinator-data.mjs, compare-runtime.mjs, evict-fixture-linux.py), taken from the issue unchanged. Seeded on Linux with
node platform-repro.mjs seed <main checkout> coordinator-matched.sqlite coordinator(Node 26.13.1, SQLite 3.54.1): 2,855 runs, 919 cancelled, 19,601 target items, 335 MB, the same fixture the report describes. The identical file (sha256 c82fdb7b…) was copied to a leased Windows Server 2025 machine (Xeon Platinum 8573C, 4 vCPU, NTFS) and run withnode compare-runtime.mjs <main checkout> coordinator-matched.sqlite <out>.json 5 <warm-file|cold-file>. No extra load was added; sampled CPU was 36-63%. Both platforms gave the same VM steps as the report (superseded lookup 14,285, 0 rows; hidden-conversation lookup 70,577, 1 row). First-page times over 5 trials each: Linux warm median 150 ms (119-214); Linux cold with mincore-verified eviction median 1.66 s (1.56-1.86), superseded lookup 0.40-0.74 s; Windows warm median 140 ms (136-150), lookup about 19 ms; Windows cold with fresh robocopy /J copies, two batches of 5: 3.50, 2.58, 2.38, 2.26, 6.41 s and 2.83, 3.29, 3.19, 3.34, 2.53 s, median 2.9 s (2.26-6.41), 1 of 120 pages over 6 s. In those runs the superseded lookup took 0.57-2.30 s and openLocalTimeline 0.91-3.46 s. Later pages had a median of 90-133 ms everywhere. To confirm the share, the same fixture was given the reporter's partial indexCREATE INDEX … ON orchestration_v2_projection_run_attempts(thread_id,run_id,root_node_id) WHERE status='superseded'and run cold on Windows: superseded lookup 9 VM steps, 0.80-0.98 ms; openLocalTimeline 0.33-0.42 s; first page median 1.88 s (1.76-1.98); 0 of 60 over budget. The reporter's 6-28 s first pages, seen with their host at 98-100% CPU, were not matched on this idle machine. The same cold-cache slow path, and its growth on Windows, was measured.Evidence
Seed each commit's fresh database with the same synthetic coordinator history, then measure ten fresh-process trials on the same Windows Server 2025 host using fresh robocopy /J copies. Each trial loads the first older-history page, repeats it, and loads ten earlier pages.
The first-page median improves by 476.144 ms (27.2%), exceeding both full observed ranges (42.451 ms and 40.180 ms). All 120 corresponding full-page hashes match. The production migration creates the covering partial index without manual indexing.
Reproduction scripts and instructions · Measurement driver · Summary
Environment: Windows Server 2025, four vCPUs, Node 26.13.1, SQLite 3.54.1. CPU samples were 0–2%; no artificial load was added. This proves the server-path performance improvement, not the reporter's overloaded-host timeout.
Not shown:
Tests
vp test run src/persistence/reconcileV2PreviewMigration.test.ts src/persistence/Migrations.test.ts src/persistence/Sqlite.test.ts(apps/server): 3 files, 22 tests passedvp run check:changed: knip, graphql, typecheck (3 packages) and tests (3 files) passedcompare-runtime.mjs … 5 cold-file, before (main) and after (fix): Windows Server 2025, 2 batches of 5 each: first page median 1,656 ms before and 1,264 ms after, superseded lookup 14,285 VM steps before and 9 after; Linux, 5 trials each: median 1,492 ms before and 1,135 ms after; 0 pages over the 6 s budgetNot in this change
Who did the work
Run by the t3code factory in T3 Code.