Skip to content

perf(index): cache query-visible index listings per snapshot - #10619

Merged
Xuanwo merged 10 commits into
lance-format:mainfrom
karthiksenv:codex/cache-query-index-listing
Nov 14, 2026
Merged

Xuanwo merged 10 commits into
lance-format:mainfrom
karthiksenv:codex/cache-query-index-listing

Conversation

@karthiksenv

@karthiksenv karthiksenv commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Warm-opening scalar index segments repeatedly processes the snapshot's complete index listing, including reader/version checks and filtering. With many segments, that repeats metadata work for each open. Refs #10414.

Cache the complete query-visible listing by store identity, manifest version, and ETag, and return its shared Arc. The internal cache key keeps the public DerivedIndexListingKey value type unchanged. Listings with incomplete best-effort legacy vector-detail inference or an unreadable format marker retry derivation on later calls. Maintenance paths continue to use load_all_indices.

A manifest without an ETag carries no generation token: a dataset dropped and recreated at the same URI restarts its version history, so a version-only key could alias the previous incarnation's listing. load_indices therefore derives the listing for that call without reading or publishing the shared cache entry, the same guard get_row_id_index applies. Regression tests seed a stale listing under the version-only key and check that an untagged snapshot neither serves nor replaces it.

Extend concurrent-load coverage to check shared results, and add tests for inference recovery and index creation/drop/historical checkout. Update fixtures that replace metadata without committing a snapshot, and account for the memory-only query listing in cache-count and serialization tests. The warm remapping-plan test replaces both raw and query listings so it still verifies that warm opens use the cached plan.

The refresh in 542336ef1 merges main e72e57140 into the branch. 9b1803285 is the merge commit and already carries the production untagged-snapshot guard; 542336ef1 adds that guard's two regressions and updates the comments that described the pre-merge behavior. Merge resolutions keep main's independent-covering malformed fixture (covering_fields = vec![999, 999], #10662) together with this branch's cache clear, and keep the typed query listing with its shared derivation and retry flag instead of main's separate details_pending/unverifiable guard, which implemented the same retry. It also retains the explicit stable-row-ID lookup and accounts for that optional entry alongside raw metadata and query-listing entries in the ANN deletion test's cache count.

Validation of e8899219a (local)

  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --profile ci --locked failed at session/index_caches.rs:315 before the change and passes after it. The public DerivedIndexListingKey comment linked to the crate-private QueryIndexListingKey, so this commit turns that one link into plain code and leaves the type private. No other files or behavior change.
  • cargo fmt --all -- --check passed.
  • cargo clippy --all --tests --benches -- -D warnings passed in the dev profile without --profile ci --locked. The workspace Clippy run on 542336ef1 with cargo --profile ci --locked is reused for this documentation-only delta.
  • The behavior suites from 542336ef1 were not rerun: this commit changes only one line of prose in a doc comment, so the compiled code and tests are identical.

Validation of 542336ef1 (local, cargo --profile ci --locked)

  • cargo check -p lance --tests --benches passed (5m31s).
  • Focused suites: loading behaviors 14 passed (concurrent Arc reuse, drop/create/historical isolation, inference retry, the untagged guard and the stale-entry regression); session index-cache keys 7 passed; remap 8 passed, including both independent-covering malformed cases; lifecycle 76 passed; frag_reuse_reader 123 passed; ANN deletion accounting 4 passed; serializing-backend prewarm 3 passed. No failures or ignored tests.
  • cargo fmt --all and cargo fmt --all -- --check are clean.
  • Full workspace cargo clippy --profile ci --locked --all --tests --benches -- -D warnings passed (5m58s).

The first hosted run on 542336ef1 exposed the strict-rustdoc failure fixed in e8899219a; otherwise the commit's behavior matches the local results above.

Earlier validation of 4943992c5, before this refresh

  • Rust, Python and Java CI passed on that revision. The ARM library suite recorded 10,262 passes, zero failures and nine ignored tests, including the concurrent-listing load, transient inference/format-marker recovery, all four ANN-deletion variants, tagged remapping and all three serialization-backend prewarm cases. License, typo and module-size workflows also passed.
  • cargo fmt --all and the archived-source formatting check passed; full cargo clippy --all --tests --benches -- -D warnings passed locally (90m09s) with all 2,756 archived source files and executable bits matching the tested source afterward.
  • Runtime tests were not completed locally on that revision; the runtime results above come from hosted CI. A test-binary build on an earlier merge was stopped as WSL approached its existing RAM and swap limits. The benchmark was not repeated after that merge.

Validation of 2da95c718, before that merge

  • Rust formatting and full Clippy passed locally.
  • Rust CI passed across Linux, ARM, macOS and Windows (8,859 passes, zero failures, nine ignored in the ARM library suite, including both vector prewarm regression cases). Python CI and Java CI passed on the same commit.
  • A local paired benchmark in WSL used release-no-lto, the same probe on base 91ef50083 and patch 1d787fee5, and nine warm trials after one warm-up. Opening all 1,024 B-tree segments fell from a median 537.817 ms to 32.338 ms, about 16.6x faster. At 256 segments the medians were 40.232 ms and 2.960 ms. Both probes passed their segment-count assertions. These are measurements of those revisions, with the patched run first; an unrelated test suite was running during the baseline compilation and measurement.

OpenAI Codex assisted with investigation, implementation, regression tests and validation.

Copy link
Copy Markdown
Contributor Author

@wjones127, could you review the proposed snapshot-cache approach or route it to the index maintainer? @tianfy17, your benchmark from #10414 would be useful for comparing this patch against the same baseline.

This remains a draft: local Clippy passed, but local runtime tests and the post-fix benchmark are still outstanding. GitHub also reports merge conflicts and failures in the platform build jobs. Guidance on the design and the validation needed before this can move toward merge would help.

@karthiksenv
karthiksenv marked this pull request as ready for review November 6, 2026 04:00

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 6, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 10, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 10, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 12, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 12, 2026
Keep main's independent-covering malformed fixture in dataset/index.rs and
this branch's cache clear before the injected raw metadata.

In index/lifecycle.rs keep the typed query-listing cache with its shared
derivation and retry_derivation recovery; that supersedes main's separate
details_pending/unverifiable guard, which implemented the same retry.
Without a manifest e-tag the query-listing key has no generation token, so a
dataset dropped and recreated at the same URI could alias a previous
incarnation's version. Skip the shared query cache entirely in that case: derive
the listing for the call and neither read nor publish an entry, matching the
row-id index's existing guard.

The new regression seeds a stale listing under the version-only key and checks
that it is neither served nor replaced; the correctness case checks an untagged
snapshot still loads its real indices and publishes nothing. Also update the
comments that still described the pre-merge "never cache" behavior.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 14, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 14, 2026
The public `DerivedIndexListingKey` doc comment linked to the
crate-private `QueryIndexListingKey`, so `RUSTDOCFLAGS="-D warnings"
cargo doc` failed on rustdoc::private_intra_doc_links. Mention the private
type as plain code instead; the docs keep the same meaning and the type
stays private.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 14, 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.

No blockers found. The documentation-only change leaves the snapshot-cache behavior unchanged from 542336ef1, where all 48 focused local regressions passed.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 14, 2026
@karthiksenv

Copy link
Copy Markdown
Contributor Author

Hi @Xuanwo, this PR is ready for review, with all six CI workflows passing. Could you take a look when you have a chance and merge it if everything looks good? Thanks for your time!

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 14, 2026
@Xuanwo
Xuanwo merged commit ef9a266 into lance-format:main Nov 14, 2026
50 of 51 checks passed
Xuanwo added a commit to kamronis/lance that referenced this pull request Nov 14, 2026
Brings the result-cache branch onto main e602c45, preserving the merged
cross-column refinement (lance-format#9127), query-listing generation token (lance-format#10619),
segment-contract rejection (lance-format#10761) and manifest/index replacement
semantics (lance-format#10698).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

K-approved Latest Gatekeeper recommendation permits acceptance. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants