Skip to content

perf(fts): short-circuit conjunction confirmations - #8354

Open
BubbleCal wants to merge 1 commit into
mainfrom
yang/oss-1707-two-phase-confirmation-order
Open

perf(fts): short-circuit conjunction confirmations#8354
BubbleCal wants to merge 1 commit into
mainfrom
yang/oss-1707-two-phase-confirmation-order

Conversation

@BubbleCal

Copy link
Copy Markdown
Contributor

What is the performance issue?

RequiredConjunctionScorer confirmed every two-phase child for each aligned candidate, even after one required child had already rejected the document. In compound FTS queries, expensive phrase confirmations could therefore run for candidates that a cheaper required clause would discard.

How does this PR improve performance?

  • Order required-clause confirmations by each scorer's stable match_cost hint, independently of query-order scoring and score-bound arithmetic.
  • Stop confirmation on the first rejected required clause and cache the result for the current document.
  • Keep scorers without a cost hint in stable query order after costed scorers, and reject invalid cost hints.
  • Preserve exact scoring and top-k behavior for phrase and nested Boolean queries across multiple fragments.

Benchmark

Scenario / metric Baseline This PR Benefit
Two-phase matches() calls for 100 aligned candidates with two required children (lower is better) 200 calls/query 120 calls/query 1.67x fewer confirmation calls

Methodology: deterministic counting-scorer canary with the same 100 aligned candidates and top-k collection path. The query-order first child has cost 10, accepts all candidates, and represents the expensive confirmation; the second child has cost 1, accepts 20% of candidates, and represents the cheap filter. The baseline (origin/main at 4d63a12ef) eagerly confirms both children for all 100 candidates. This PR confirms the cheap child 100 times and the expensive child only for the 20 survivors. This measures confirmation work, not wall-clock latency.

Validation

  • cargo test -p lance-index --lib scalar::inverted::compound::tests (12 passed)
  • cargo test -p lance --lib dataset::tests::dataset_index::test_compound_phrase_confirmation_short_circuit_is_exact -- --exact (1 passed)
  • cargo test -p lance --lib dataset::tests::dataset_index::test_same_column_compound_scorer_is_exact_and_bounded -- --exact (1 passed)
  • cargo fmt --all -- --check
  • cargo clippy --all --tests --benches -- -D warnings
  • git diff origin/main...HEAD --check

No public API or index-format changes.

Closes OSS-1707.

@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 addresses eager MUST-clause confirmation at the right layer: a stable, cost-ordered index controls only two-phase confirmation, while scoring and bounds remain in query order. The deterministic canary demonstrates the claimed 200-to-120 reduction, and multi-fragment phrase plus nested-Boolean coverage preserves exact results.

@github-actions github-actions Bot added the A-index Vector index, linalg, tokenizer label Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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 performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants