perf(fts): index residual compound rows once - #8818
Conversation
There was a problem hiding this comment.
❌ Gate recommendation: request changes.
1 fixed / 3 remain. The expanded physical-file identity now rejects cross-base replacements and base rebinding, but this head still does not compile and deferred remapping can still advance the only history watermark past stale physical postings.
Keep immutable physical-source provenance distinct from the remap watermark, and correct the iterator and path arguments so the focused regressions can build and exercise that unsafe transition.
0f6549f to
1eadba4
Compare
c5700f2 to
ff57621
Compare
There was a problem hiding this comment.
The visibility adjustment keeps the query-local stats type confined through its crate-only re-export, and the affected crate check passes. The author intentionally accepts that cross-arm ranking may drift until indexing catches up; no further change is requested for that trade-off.
Performance issue
Partially indexed row-granularity FTS currently falls back to a separate flat residual scan for each leaf of a compound query. A Boolean, Boost, or same-field MultiMatch query can therefore read and tokenize the same small append-only tail repeatedly.
Change
Add a same-column hybrid path for bounded compound queries with small unindexed tails:
The scoring contract intentionally matches the existing partially indexed
Rowflat-search approximation:This is not the
fast_searchcontract:fast_searchomits residual rows, while this path searches them approximately.The planner fails closed to the established fallback for cross-column queries, Phrase or fuzzy leaves, filters, external row masks, deletions, fragment-scoped scans, list-element documents, unbounded queries, incomplete or overlapping physical coverage, rewritten/overlaid indexed sources, all-unindexed datasets, and residual tails above 100,000 physical rows. Empty analyzed term sets short-circuit without scanning the residual input.
Tests cover query-local term allowlisting and mixed corpus statistics, explicit row IDs, residual-only TF ordering, Boost, Boolean MUST/SHOULD/MUST_NOT, same-column MultiMatch, score ties, empty analyzed queries, bounded parallel shards, tokenizer reuse, fallback gates, and unsafe physical row-domain transitions.
Benchmark
Serialized current-head ABBA benchmark on one exclusive
c4-highmem-16VM (16 vCPU, 121 GiB RAM,us-central1-c) usingrelease-with-debugand 8 workers. The frozen fixture contains 10,010,000 rows: 10,000,000 indexed rows plus 10,000 unindexed append-only rows.Baseline:
338e100ca76e91ff593fa0d479245e1209489a8fThis PR:
7c30fa8d2296331576d1e6a10729f744bba62c55Warm c1 uses one query at a time; warm c5 uses five frozen queries concurrently. Both cover
must_should,should_sum, andboost_negativeat k=10/100, with one prewarm, one warmup, three timed repetitions, and two ABBA trials per arm. Cold runs drop the page cache before every arm and report the mean of two first-query trials.should_sum, k=10 p50 (lower is better)should_sum, k=100 p50 (lower is better)Activation preflight passed all 18 shape/query/k plans with
HybridCompoundFtsScorerand without the flat fallback. Across 18 warm-c1, 90 warm-c5, and two cold ordered row+f32 digest cases, there was zero intra-build drift. This fixture also had zero observed cross-build digest changes, but that observation is not an exactness guarantee for arbitrary residual distributions.Fixture provenance SHA256:
dbd566d64c923b220d668718231d578a5ca075fe20708a3e4f9ecc40c9b7dcb4. Query manifest SHA256:2efbbf779e213918c33d7517d069994a05a0b30cf9a9af4d22f9d0c9657d7dd1. Baseline module SHA256:a07439a03a0c7a5a367c3d3d37846283da528943bf3b0a189e4e9c37b2b33ee5. Target module SHA256:56a455c8e1d9e2746f8a8da12ba7f495e4ca0e526b1906fc3cd2d550e1cec617. Harness SHA256:454798e91c85ff3f98f4857ed02b79d69c67dca5c0f755feba24566347520a12. Analyzer SHA256:12e2e83fbd3153e37088abd9bd3d6839713818946beffabfd7255c920442b3a7. Results fingerprint SHA256:228daf0fd258821a1989ae2955be4a22e7e2f23811293376ad4edde1bfa328c2.Validation
cargo fmt --all -- --checkgit diff --check