Commit d35a232
authored
perf(fts): bound compound score-floor tie buffering (#8161)
## What is the performance issue?
Compound FTS preserves exact `(score DESC, row_id ASC)` ordering by
retaining every candidate tied at the kth score until modern document
IDs are resolved to row addresses. Large BM25 tie groups therefore make
the candidate heap, address-resolution input, and final sort
proportional to the full tie population, even when `limit=1`.
## How does this PR improve performance?
- Keep the final global top-k heap keyed by resolved row ID.
- Bound unresolved score-floor candidates at `limit + 128`.
- Resolve modern addresses in batches of at most 128 candidates.
- If a partition exceeds the unresolved bound, load its resident address
projection and retry only that partition with exact row-ID keys.
- Preserve the legacy document path and the shared score-only
competitive threshold.
- Expose addresses resolved, batch count, peak batch size, score-floor
overflow count, and peak buffered candidates as execution metrics.
## Measurement
| Scenario / metric | Baseline | This PR | Benefit |
| --- | ---: | ---: | ---: |
| `limit=1`, 512 equal-score candidates; peak unresolved candidates
(lower is better) | 512 candidates | 129 candidates | 3.97x smaller peak
|
Measured deterministically with the in-memory compound collector
regression in the local macOS debug test profile. This table measures
candidate working-set size, not wall-clock latency. Comparable MMLB
latency and memory benchmarks have not yet been run, so this PR does not
claim a latency or throughput improvement.
## Correctness
A 384-row equal-score regression spans reversed committed segments and
multiple modern partitions. It compares limited output with the
exhaustive oracle, exercises both bounded batch resolution and overflow
retry, and verifies the emitted resolution metrics.
Linear:
[OSS-1618](https://linear.app/lancedb/issue/OSS-1618/bound-compound-fts-score-floor-tie-handling-by-resolved-row-id)
## Validation
- `cargo fmt --all -- --check`
- `cargo clippy --all --tests --benches -- -D warnings`
- `cargo test -p lance-index scalar::inverted::compound::tests --lib` (6
passed)
- `cargo test -p lance compound --lib` (5 passed)
- `git diff --check`1 parent 5d1f900 commit d35a232
5 files changed
Lines changed: 509 additions & 153 deletions
File tree
- rust
- lance-index-core/src
- lance-index/src/scalar/inverted
- lance/src
- dataset/tests
- io/exec
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
88 | 109 | | |
89 | 110 | | |
90 | 111 | | |
| |||
0 commit comments