Skip to content

perf(fts): cache the num_tokens-only DocSet on LazyDocSet#7600

Merged
BubbleCal merged 1 commit into
mainfrom
yang/fts-cache-tokens-only-docset
Jul 6, 2026
Merged

perf(fts): cache the num_tokens-only DocSet on LazyDocSet#7600
BubbleCal merged 1 commit into
mainfrom
yang/fts-cache-tokens-only-docset

Conversation

@BubbleCal

@BubbleCal BubbleCal commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

ensure_num_tokens_loaded rebuilt the num_tokens-only DocSet from the
cached arrow column on every call, copying the whole column (tens of MB per
partition) once per query per partition. Materialize it once in a OnceCell
like the full DocSet, and account for it in deep_size_of.

Measured vs its merge-base

Per-branch-tip wheels on the 200M-doc legacy index (338 partitions), 1000
queries × 8 concurrent, 400G index cache. The rebuild only happens while a
partition's DocSet is deferred (not yet fully materialized), so the win shows
on the not-yet-prewarmed path, and the fix is exactly neutral once the index
is warm:

protocol query base this PR
no prewarm, steady-state passes single-term k10 0.304s / 27 qps 0.076s / 105 qps (4.0×)
no prewarm, steady-state passes 3-word OR k10 0.359s / 22 qps 0.179s / 45 qps (2.0×)
prewarmed single-term k10 0.027s 0.027s (neutral)
prewarmed 3-word OR k10 / k100 0.133s / 0.258s 0.133s / 0.257s (neutral)

In the stacked V3 setup (#7466 and its followers) partitions serve queries
from the tokens-only DocSet indefinitely, where this same rebuild dominated
hot single-term queries (250ms → 3ms when the cache landed there).

Independent of the block-size/impact PR stack; applies to any FTS query.

🤖 Generated with Claude Code

ensure_num_tokens_loaded rebuilt the DocSet from the cached arrow column on
every call, copying the whole num_tokens array (tens of MB per partition)
once per query per partition — profiled at ~50% of single-term query time
and a large slice of every warm query. Materialize it once in a OnceCell
like the full DocSet, and account for it in deep_size_of.
@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer performance labels Jul 3, 2026
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ust/lance-index/src/scalar/inverted/lazy_docset.rs 76.92% 0 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@BubbleCal BubbleCal merged commit a96d0d7 into main Jul 6, 2026
33 checks passed
@BubbleCal BubbleCal deleted the yang/fts-cache-tokens-only-docset branch July 6, 2026 08:21
BubbleCal pushed a commit that referenced this pull request Jul 6, 2026
…igurable

Reconciles #7600's tokens_only DocSet cache with this branch's
quantized_scoring flag: the cached num_tokens-only DocSet is built with
quantized scoring applied inside the OnceCell init, matching how
ensure_loaded stamps the full DocSet.
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