Skip to content

perf(fts): remove benchmark metrics from query hot paths - #8825

Merged
BubbleCal merged 1 commit into
mainfrom
yang/fts-prod-metrics-cleanup
Aug 27, 2026
Merged

BubbleCal merged 1 commit into
mainfrom
yang/fts-prod-metrics-cleanup

Conversation

@BubbleCal

@BubbleCal BubbleCal commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Performance issue

Recent compound FTS optimizations exposed 41 validation metrics through the production DataFusion operator. This registered 58 metrics per FTS execution partition in total and kept benchmark bookkeeping in document, candidate, and window loops.

How this improves performance

  • Remove optimization-validation metrics from the production MetricsCollector surface and FtsIndexMetrics registration.
  • Remove per-document phrase counters, per-candidate AND counters, per-window SHOULD counters, candidate-buffer high-water tracking, and phase-only WAND/cross-column bookkeeping.
  • Keep only coarse production observability: generic index load/cache/I/O/comparison metrics, partitions searched, scorer build time, segment bind time, and DataFusion baseline metrics.
  • Keep useful algorithm activation counters local to unit tests with #[cfg(test)] where practical.
  • Document that benchmark-only instrumentation must stay in test or benchmark hooks.

The FTS-specific registrations fall from 44 to 3. Including unchanged generic index and DataFusion baseline metrics, the total per FTS execution partition falls from 58 to 17.

Benchmark

Both runs compared baseline 0ac7d22fb35793fbf34b63e52061c1f91ea5722b with this PR at 57d50914b0596a18ee2cce3180cf69048a625e64 on yang-agent-fts-compound-20260819-c, a GCP c4-highmem-16 VM in us-central1-c, using the release-with-debug profile. Lower latency and higher QPS are better.

Protocol: five stratified queries, must_should, should_sum, boost_negative, and phrase_should, k=10,100, eight threads, one warmup plus three measured repetitions per trial, prewarmed index, and ABBA order (baseline, PR, PR, baseline) with forward/reverse case order. The manifest query IDs were normalized to contiguous IDs without changing query text, order, or source rows; its SHA256 is 2efbbf779e213918c33d7517d069994a05a0b30cf9a9af4d22f9d0c9657d7dd1.

Fully indexed 10M rows: compound fast path

All 24 preflight cases used CompoundFtsScorer in both builds. Full plan text and ordered row/score digests were identical. All 120 timed ordered row+f32 digest cases matched exactly, with zero intra-build or cross-build drift.

Scenario / metric Baseline This PR Benefit
boost_negative, k=10, QPS 549.823 q/s 628.008 q/s 1.1422x throughput
boost_negative, k=100, QPS 329.995 q/s 377.150 q/s 1.1429x throughput
must_should, k=10, QPS 904.788 q/s 1,200.318 q/s 1.3266x throughput
must_should, k=100, QPS 915.663 q/s 1,058.655 q/s 1.1562x throughput
phrase_should, k=10, QPS 559.690 q/s 579.838 q/s 1.0360x throughput
phrase_should, k=100, QPS 144.353 q/s 167.964 q/s 1.1636x throughput
should_sum, k=10, QPS 365.469 q/s 482.858 q/s 1.3212x throughput
should_sum, k=100, QPS 387.701 q/s 410.368 q/s 1.0585x throughput

Across these cases, p50 latency improved by 1.0527x to 1.2187x.

Result root: /mnt/benchmark-ssd/mmlb-queue/08-compound-partial-layers/results/metrics-cleanup-57d50914b-full-index-abba2 (results-fingerprint.json tree SHA256 a98748f9e4e3e942312cfb40943d7969d0836c8be69814c3b2c4dc683ca81cfd).

10M indexed + 100k unindexed rows: current fast-search fallback

Current main plans this partially indexed workload into the leaf BooleanQuery/BoostQuery fallback rather than CompoundFtsScorer. All 24 preflight plans were byte-for-byte identical between builds, and all 120 timed ordered row+f32 digest cases matched exactly. The QPS ratios straddle 1.0x (0.9689x to 1.0261x), so this longer fallback workload shows no clear performance change.

Scenario / metric Baseline This PR Benefit
boost_negative, k=10, QPS 27.251 q/s 27.762 q/s 1.0188x throughput
boost_negative, k=100, QPS 27.673 q/s 28.287 q/s 1.0222x throughput
must_should, k=10, QPS 40.457 q/s 39.199 q/s 0.9689x throughput
must_should, k=100, QPS 40.415 q/s 40.158 q/s 0.9937x throughput
phrase_should, k=10, QPS 30.502 q/s 30.390 q/s 0.9963x throughput
phrase_should, k=100, QPS 30.235 q/s 30.506 q/s 1.0090x throughput
should_sum, k=10, QPS 97.810 q/s 100.368 q/s 1.0261x throughput
should_sum, k=100, QPS 97.829 q/s 98.694 q/s 1.0088x throughput

Result root: /mnt/benchmark-ssd/mmlb-queue/08-compound-partial-layers/results/metrics-cleanup-57d50914b-abba2 (results-fingerprint.json tree SHA256 84d789a5ef3e7e4589cb78573ca06af562dae028d896f8a1308d11f226663f61).

Validation

  • cargo fmt --all
  • git diff --check
  • Full tests and clippy run in CI, per the current workflow.

@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer performance labels Aug 27, 2026
@BubbleCal
BubbleCal force-pushed the yang/fts-prod-metrics-cleanup branch 4 times, most recently from 5c83364 to 57d5091 Compare August 27, 2026 13:16
@BubbleCal
BubbleCal marked this pull request as ready for review August 27, 2026 13:57

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The change removes validation-only registration and bookkeeping from the FTS document, candidate, and window hot paths while retaining coarse production observability and test-only activation counters. The maintained oracle/equivalence tests and the controlled ABBA measurements support both result stability and the path-specific performance gain.

Please mark this PR with the breaking-change label.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 27, 2026
@BubbleCal
BubbleCal force-pushed the yang/fts-prod-metrics-cleanup branch from 57d5091 to 3d37d59 Compare August 27, 2026 15:08
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 27, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The rebased patch remains a metrics-only cleanup: it removes validation bookkeeping from hot paths without altering scoring behavior or the newly shared MultiMatch prefilter contract. The result-stability and path-specific performance evidence continues to support the change.

Please mark this PR with the breaking-change label.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 27, 2026
@BubbleCal
BubbleCal merged commit 6e5c5ba into main Aug 27, 2026
45 of 46 checks passed
@BubbleCal
BubbleCal deleted the yang/fts-prod-metrics-cleanup branch August 27, 2026 15:55
sbrunk added a commit to sbrunk/lance that referenced this pull request Sep 8, 2026
…AXSCORE

The cross-field scan scores every candidate in the union of the query terms'
postings. This adds the term-at-a-time MAXSCORE loop, which skips scoring a
candidate whose upper bound cannot reach the running k-th score.

Each term carries a constant ceiling `idf' · BM25_DOC_WEIGHT_UPPER_BOUND`
(Lucene's `CombinedFieldQuery` uses a per-term constant rather than a per-block
maximum, because the BM25F blend makes a block-max meaningless across columns).
Terms are ordered by ceiling and split into an essential suffix, which drives
candidate discovery, and a non-essential prefix, which is only probed once a
candidate's partial score makes it viable. `BM25_DOC_WEIGHT_UPPER_BOUND` is the
ceiling `doc_weight` already clamps to, so the bound holds by construction
rather than by trusting the corpus statistics.

Reuses `wand::score_sum_cannot_compete` for the prune test, widening its
visibility to `pub(super)`. `CompetitiveFloorMode::Exclusive` matches this
scan's score-only strict-`<` collector.

The top-k scores are identical to the exhaustive scan by construction, and the
tests assert exactly that: `exact_topk_scores` rescores every candidate the
merged scan would and compares bit-for-bit, over OR and AND, every k, absent
columns, a masked prefilter, ties and a clamped zero-idf term. Neither scan
orders equal scores, so the plan's `(score DESC, row_id ASC)` sort stays what
decides which of two tied rows comes first.

`MaxscoreStats` counts candidates discovered against candidates pruned and
scored. Per-candidate bookkeeping does not belong on the production
`MetricsCollector`, which lance-format#8825 deliberately reduced to coarse observability,
so the counters reach dev targets the way the brute-force oracle already does:
the `maxscore` module stays private and the new `test-scan-stats` feature
re-exports `MaxscoreStats` next to `combined_fields_search_with_stats`, which
is the whole implementation with plain `combined_fields_search` delegating to
it and dropping the stats. Nothing is added to the default path. The unit tests
assert on those counts directly, so a gate that never fires cannot pass as
correct-but-inert.
sbrunk added a commit to sbrunk/lance that referenced this pull request Sep 8, 2026
…AXSCORE

The cross-field scan scores every candidate in the union of the query terms'
postings. This adds the term-at-a-time MAXSCORE loop, which skips scoring a
candidate whose upper bound cannot reach the running k-th score.

Each term carries a constant ceiling `idf' · BM25_DOC_WEIGHT_UPPER_BOUND`
(Lucene's `CombinedFieldQuery` uses a per-term constant rather than a per-block
maximum, because the BM25F blend makes a block-max meaningless across columns).
Terms are ordered by ceiling and split into an essential suffix, which drives
candidate discovery, and a non-essential prefix, which is only probed once a
candidate's partial score makes it viable. `BM25_DOC_WEIGHT_UPPER_BOUND` is the
ceiling `doc_weight` already clamps to, so the bound holds by construction
rather than by trusting the corpus statistics.

Reuses `wand::score_sum_cannot_compete` for the prune test, widening its
visibility to `pub(super)`. `CompetitiveFloorMode::Exclusive` matches this
scan's score-only strict-`<` collector.

The top-k scores are identical to the exhaustive scan by construction, and the
tests assert exactly that: `exact_topk_scores` rescores every candidate the
merged scan would and compares bit-for-bit, over OR and AND, every k, absent
columns, a masked prefilter, ties and a clamped zero-idf term.

Both scans order equal scores by `RankedDoc`, so the top-k is settled in the
scan rather than by the plan's sort, which the fully covered plan does not have.
The prune stays `Exclusive`: discovery is ascending by row id, so a candidate
that only ties the k-th score always loses the tiebreak to the incumbents, and
rejecting it drops nothing the collector would have kept.
`test_combined_maxscore_ties_keep_lowest_row_ids` pins that.

`MaxscoreStats` counts candidates discovered against candidates pruned and
scored. Per-candidate bookkeeping does not belong on the production
`MetricsCollector`, which lance-format#8825 deliberately reduced to coarse observability,
so the counters reach dev targets the way the brute-force oracle already does:
the `maxscore` module stays private and the new `test-scan-stats` feature
re-exports `MaxscoreStats` next to `combined_fields_search_with_stats`, which
is the whole implementation with plain `combined_fields_search` delegating to
it and dropping the stats. Nothing is added to the default path. The unit tests
assert on those counts directly, so a gate that never fires cannot pass as
correct-but-inert.
sbrunk added a commit to sbrunk/lance that referenced this pull request Sep 8, 2026
…AXSCORE

The cross-field scan scores every candidate in the union of the query terms'
postings. This adds the term-at-a-time MAXSCORE loop, which skips scoring a
candidate whose upper bound cannot reach the running k-th score.

Each term carries a constant ceiling `idf' · BM25_DOC_WEIGHT_UPPER_BOUND`
(Lucene's `CombinedFieldQuery` uses a per-term constant rather than a per-block
maximum, because the BM25F blend makes a block-max meaningless across columns).
Terms are ordered by ceiling and split into an essential suffix, which drives
candidate discovery, and a non-essential prefix, which is only probed once a
candidate's partial score makes it viable. `BM25_DOC_WEIGHT_UPPER_BOUND` is the
ceiling `doc_weight` already clamps to, so the bound holds by construction
rather than by trusting the corpus statistics.

Reuses `wand::score_sum_cannot_compete` for the prune test, widening its
visibility to `pub(super)`. `CompetitiveFloorMode::Exclusive` matches this
scan's score-only strict-`<` collector.

The top-k scores are identical to the exhaustive scan by construction, and the
tests assert exactly that: `exact_topk_scores` rescores every candidate the
merged scan would and compares bit-for-bit, over OR and AND, every k, absent
columns, a masked prefilter, ties and a clamped zero-idf term.

Both scans order equal scores by `RankedDoc`, so the top-k is settled in the
scan rather than by the plan's sort, which the fully covered plan does not have.
The prune stays `Exclusive`: discovery is ascending by row id, so a candidate
that only ties the k-th score always loses the tiebreak to the incumbents, and
rejecting it drops nothing the collector would have kept.
`test_combined_maxscore_ties_keep_lowest_row_ids` pins that.

`MaxscoreStats` counts candidates discovered against candidates pruned and
scored. Per-candidate bookkeeping does not belong on the production
`MetricsCollector`, which lance-format#8825 deliberately reduced to coarse observability,
so the counters reach dev targets the way the brute-force oracle already does:
the `maxscore` module stays private and the new `test-scan-stats` feature
re-exports `MaxscoreStats` next to `combined_fields_search_with_stats`, which
is the whole implementation with plain `combined_fields_search` delegating to
it and dropping the stats. Nothing is added to the default path. The unit tests
assert on those counts directly, so a gate that never fires cannot pass as
correct-but-inert.
sbrunk added a commit to sbrunk/lance that referenced this pull request Sep 25, 2026
…AXSCORE

The cross-field scan scores every candidate in the union of the query terms'
postings. This adds the term-at-a-time MAXSCORE loop, which skips scoring a
candidate whose upper bound cannot reach the running k-th score.

Each term carries a constant ceiling `idf' · BM25_DOC_WEIGHT_UPPER_BOUND`
(Lucene's `CombinedFieldQuery` uses a per-term constant rather than a per-block
maximum, because the BM25F blend makes a block-max meaningless across columns).
Terms are ordered by ceiling and split into an essential suffix, which drives
candidate discovery, and a non-essential prefix, which is only probed once a
candidate's partial score makes it viable. `BM25_DOC_WEIGHT_UPPER_BOUND` is the
ceiling `doc_weight` already clamps to, so the bound holds by construction
rather than by trusting the corpus statistics.

Reuses `wand::score_sum_cannot_compete` for the prune test, widening its
visibility to `pub(super)`. `CompetitiveFloorMode::Exclusive` matches this
scan's score-only strict-`<` collector.

The top-k scores are identical to the exhaustive scan by construction, and the
tests assert exactly that: `exact_topk_scores` rescores every candidate the
merged scan would and compares bit-for-bit, over OR and AND, every k, absent
columns, a masked prefilter, ties and a clamped zero-idf term.

Both scans order equal scores by `RankedDoc`, so the top-k is settled in the
scan rather than by the plan's sort, which the fully covered plan does not have.
The prune stays `Exclusive`: discovery is ascending by row id, so a candidate
that only ties the k-th score always loses the tiebreak to the incumbents, and
rejecting it drops nothing the collector would have kept.
`test_combined_maxscore_ties_keep_lowest_row_ids` pins that.

`MaxscoreStats` counts candidates discovered against candidates pruned and
scored. Per-candidate bookkeeping does not belong on the production
`MetricsCollector`, which lance-format#8825 deliberately reduced to coarse observability,
so the counters reach dev targets the way the brute-force oracle already does:
the `maxscore` module stays private and the new `test-scan-stats` feature
re-exports `MaxscoreStats` next to `combined_fields_search_with_stats`, which
is the whole implementation with plain `combined_fields_search` delegating to
it and dropping the stats. Nothing is added to the default path. The unit tests
assert on those counts directly, so a gate that never fires cannot pass as
correct-but-inert.
sbrunk added a commit to sbrunk/lance that referenced this pull request Sep 25, 2026
…AXSCORE

The cross-field scan scores every candidate in the union of the query terms'
postings. This adds the term-at-a-time MAXSCORE loop, which skips scoring a
candidate whose upper bound cannot reach the running k-th score.

Each term carries a constant ceiling `idf' · BM25_DOC_WEIGHT_UPPER_BOUND`
(Lucene's `CombinedFieldQuery` uses a per-term constant rather than a per-block
maximum, because the BM25F blend makes a block-max meaningless across columns).
Terms are ordered by ceiling and split into an essential suffix, which drives
candidate discovery, and a non-essential prefix, which is only probed once a
candidate's partial score makes it viable. `BM25_DOC_WEIGHT_UPPER_BOUND` is the
ceiling `doc_weight` already clamps to, so the bound holds by construction
rather than by trusting the corpus statistics.

Reuses `wand::score_sum_cannot_compete` for the prune test, widening its
visibility to `pub(super)`. `CompetitiveFloorMode::Exclusive` matches this
scan's score-only strict-`<` collector.

The top-k scores are identical to the exhaustive scan by construction, and the
tests assert exactly that: `exact_topk_scores` rescores every candidate the
merged scan would and compares bit-for-bit, over OR and AND, every k, absent
columns, a masked prefilter, ties and a clamped zero-idf term.

Both scans order equal scores by `RankedDoc`, so the top-k is settled in the
scan rather than by the plan's sort, which the fully covered plan does not have.
The prune stays `Exclusive`: discovery is ascending by row id, so a candidate
that only ties the k-th score always loses the tiebreak to the incumbents, and
rejecting it drops nothing the collector would have kept.
`test_combined_maxscore_ties_keep_lowest_row_ids` pins that.

`MaxscoreStats` counts candidates discovered against candidates pruned and
scored. Per-candidate bookkeeping does not belong on the production
`MetricsCollector`, which lance-format#8825 deliberately reduced to coarse observability,
so the counters reach dev targets the way the brute-force oracle already does:
the `maxscore` module stays private and the new `test-scan-stats` feature
re-exports `MaxscoreStats` next to `combined_fields_search_with_stats`, which
is the whole implementation with plain `combined_fields_search` delegating to
it and dropping the stats. Nothing is added to the default path. The unit tests
assert on those counts directly, so a gate that never fires cannot pass as
correct-but-inert.
sbrunk added a commit to sbrunk/lance that referenced this pull request Sep 25, 2026
…AXSCORE

The cross-field scan scores every candidate in the union of the query terms'
postings. This adds the term-at-a-time MAXSCORE loop, which skips scoring a
candidate whose upper bound cannot reach the running k-th score.

Each term carries a constant ceiling `idf' · BM25_DOC_WEIGHT_UPPER_BOUND`
(Lucene's `CombinedFieldQuery` uses a per-term constant rather than a per-block
maximum, because the BM25F blend makes a block-max meaningless across columns).
Terms are ordered by ceiling and split into an essential suffix, which drives
candidate discovery, and a non-essential prefix, which is only probed once a
candidate's partial score makes it viable. `BM25_DOC_WEIGHT_UPPER_BOUND` is the
ceiling `doc_weight` already clamps to, so the bound holds by construction
rather than by trusting the corpus statistics.

Reuses `wand::score_sum_cannot_compete` for the prune test, widening its
visibility to `pub(super)`. `CompetitiveFloorMode::Exclusive` matches this
scan's score-only strict-`<` collector.

The top-k scores are identical to the exhaustive scan by construction, and the
tests assert exactly that: `exact_topk_scores` rescores every candidate the
merged scan would and compares bit-for-bit, over OR and AND, every k, absent
columns, a masked prefilter, ties and a clamped zero-idf term.

Both scans order equal scores by `RankedDoc`, so the top-k is settled in the
scan rather than by the plan's sort, which the fully covered plan does not have.
The prune stays `Exclusive`: discovery is ascending by row id, so a candidate
that only ties the k-th score always loses the tiebreak to the incumbents, and
rejecting it drops nothing the collector would have kept.
`test_combined_maxscore_ties_keep_lowest_row_ids` pins that.

`MaxscoreStats` counts candidates discovered against candidates pruned and
scored. Per-candidate bookkeeping does not belong on the production
`MetricsCollector`, which lance-format#8825 deliberately reduced to coarse observability,
so the counters reach dev targets the way the brute-force oracle already does:
the `maxscore` module stays private and the new `test-scan-stats` feature
re-exports `MaxscoreStats` next to `combined_fields_search_with_stats`, which
is the whole implementation with plain `combined_fields_search` delegating to
it and dropping the stats. Nothing is added to the default path. The unit tests
assert on those counts directly, so a gate that never fires cannot pass as
correct-but-inert.
sbrunk added a commit to sbrunk/lance that referenced this pull request Sep 26, 2026
…AXSCORE

The cross-field scan scores every candidate in the union of the query terms'
postings. This adds the term-at-a-time MAXSCORE loop, which skips scoring a
candidate whose upper bound cannot reach the running k-th score.

Each term carries a constant ceiling `idf' · BM25_DOC_WEIGHT_UPPER_BOUND`
(Lucene's `CombinedFieldQuery` uses a per-term constant rather than a per-block
maximum, because the BM25F blend makes a block-max meaningless across columns).
Terms are ordered by ceiling and split into an essential suffix, which drives
candidate discovery, and a non-essential prefix, which is only probed once a
candidate's partial score makes it viable. `BM25_DOC_WEIGHT_UPPER_BOUND` is the
ceiling `doc_weight` already clamps to, so the bound holds by construction
rather than by trusting the corpus statistics.

Reuses `wand::score_sum_cannot_compete` for the prune test, widening its
visibility to `pub(super)`. `CompetitiveFloorMode::Exclusive` matches this
scan's score-only strict-`<` collector.

The top-k scores are identical to the exhaustive scan by construction, and the
tests assert exactly that: `exact_topk_scores` rescores every candidate the
merged scan would and compares bit-for-bit, over OR and AND, every k, absent
columns, a masked prefilter, ties and a clamped zero-idf term.

Both scans order equal scores by `RankedDoc`, so the top-k is settled in the
scan rather than by the plan's sort, which the fully covered plan does not have.
The prune stays `Exclusive`: discovery is ascending by row id, so a candidate
that only ties the k-th score always loses the tiebreak to the incumbents, and
rejecting it drops nothing the collector would have kept.
`test_combined_maxscore_ties_keep_lowest_row_ids` pins that.

`MaxscoreStats` counts candidates discovered against candidates pruned and
scored. Per-candidate bookkeeping does not belong on the production
`MetricsCollector`, which lance-format#8825 deliberately reduced to coarse observability,
so the counters reach dev targets the way the brute-force oracle already does:
the `maxscore` module stays private and the new `test-scan-stats` feature
re-exports `MaxscoreStats` next to `combined_fields_search_with_stats`, which
is the whole implementation with plain `combined_fields_search` delegating to
it and dropping the stats. Nothing is added to the default path. The unit tests
assert on those counts directly, so a gate that never fires cannot pass as
correct-but-inert.
sbrunk added a commit to sbrunk/lance that referenced this pull request Sep 30, 2026
…AXSCORE

The cross-field scan scores every candidate in the union of the query terms'
postings. This adds the term-at-a-time MAXSCORE loop, which skips scoring a
candidate whose upper bound cannot reach the running k-th score.

Each term carries a constant ceiling `idf' · BM25_DOC_WEIGHT_UPPER_BOUND`
(Lucene's `CombinedFieldQuery` uses a per-term constant rather than a per-block
maximum, because the BM25F blend makes a block-max meaningless across columns).
Terms are ordered by ceiling and split into an essential suffix, which drives
candidate discovery, and a non-essential prefix, which is only probed once a
candidate's partial score makes it viable. `BM25_DOC_WEIGHT_UPPER_BOUND` is the
ceiling `doc_weight` already clamps to, so the bound holds by construction
rather than by trusting the corpus statistics.

Reuses `wand::score_sum_cannot_compete` for the prune test, widening its
visibility to `pub(super)`. `CompetitiveFloorMode::Exclusive` matches this
scan's score-only strict-`<` collector.

The top-k scores are identical to the exhaustive scan by construction, and the
tests assert exactly that: `exact_topk_scores` rescores every candidate the
merged scan would and compares bit-for-bit, over OR and AND, every k, absent
columns, a masked prefilter, ties and a clamped zero-idf term.

Both scans order equal scores by `RankedDoc`, so the top-k is settled in the
scan rather than by the plan's sort, which the fully covered plan does not have.
The prune stays `Exclusive`: discovery is ascending by row id, so a candidate
that only ties the k-th score always loses the tiebreak to the incumbents, and
rejecting it drops nothing the collector would have kept.
`test_combined_maxscore_ties_keep_lowest_row_ids` pins that.

`MaxscoreStats` counts candidates discovered against candidates pruned and
scored. Per-candidate bookkeeping does not belong on the production
`MetricsCollector`, which lance-format#8825 deliberately reduced to coarse observability,
so the counters reach dev targets the way the brute-force oracle already does:
the `maxscore` module stays private and the new `test-scan-stats` feature
re-exports `MaxscoreStats` next to `combined_fields_search_with_stats`, which
is the whole implementation with plain `combined_fields_search` delegating to
it and dropping the stats. Nothing is added to the default path. The unit tests
assert on those counts directly, so a gate that never fires cannot pass as
correct-but-inert.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer K-approved Latest Gatekeeper recommendation permits acceptance. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants