Repository navigation
perf(server): keep message bodies out of search ranking sorts - #23921
UtkarshUsername wants to merge 1 commit into
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused optimization of the existing thread-search query: ranking and limiting now operate on metadata and IDs before retrieving the selected message bodies. The accompanying tests cover ordering, limits, literal matching, and snippets, with no schema, API, default, or deployment changes. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Superseded by #24343. |
Problem
Thread search carries every matching message body through ranking, causing large temporary sorts and repeated JSON extraction in bigger histories.
Change
Rank and limit message IDs and metadata first, then fetch the returned bodies through the existing primary-key index. Preserve matching, ranking, snippets, and result order.
Scope and approval
Submitted under the exception for a small, focused fix to an obvious defect: thread search unnecessarily carries full message bodies through ranking, causing large temporary writes on matching histories. This changes only the existing query and its tests, preserving matching, ranking, snippets, and result order. No schema, contract, or product behavior changes.
Verification
Service latency when every message matches, limit 50:
Fixture with long messages: logical writes fell from approximately 167 MB/search to zero in separate Windows process-counter probes. Peak RSS stayed similar; native SQLite allocations were not sized. Logical transfers are not physical disk bytes.
Real service on Node 26.12.1/SQLite 3.54.0, synthetic histories with 100 active threads, five isolated candidate trials and paired baseline controls. Maximum A/A difference for these rows: 11.4%. Timings exclude network/UI. Sparse/no-match searches and the smallest fixture with one short message per thread stayed within noise; substring scanning remains.
Benchmarks and tests cover final commit
046f086; the committed query matches the measured source.vp test run apps/server/src/orchestration-v2/ThreadSearch.test.ts: four passed, including ranking/ties, limits, literal wildcards, long snippets, eligibility, and reader worker concurrency. Another 9,600 generated SQLite comparisons matched the baseline.vp run check:changed upstream/main: passed format, lint, knip, GraphQL generation, affected-package typechecks, and adjacent tests.Implemented with GPT-6.1 Sol (high) through Codex in T3 Code.