Skip to content

feat: support prewarm for IVF-based ANN indices - #6090

Merged
LuQQiu merged 4 commits into
lance-format:mainfrom
wjones127:feat/prewarm-ivf
Mar 4, 2026
Merged

LuQQiu merged 4 commits into
lance-format:mainfrom
wjones127:feat/prewarm-ivf

Conversation

@wjones127

@wjones127 wjones127 commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Calling prewarm on IVF indices will now load the sub index partitions into the cache.

Related to #3698

@github-actions github-actions Bot added the enhancement New feature or request label Mar 4, 2026
@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

PR Review: feat: support prewarm for IVF-based ANN indices

P1: Hardcoded concurrency in v2 IVFIndex

In rust/lance/src/index/vector/ivf/v2.rs, the prewarm method uses a hardcoded Some(8) for try_for_each_concurrent:

futures::stream::iter(0..self.ivf.num_partitions())
    .map(Ok)
    .try_for_each_concurrent(Some(8), |part_id| { ... })

The legacy IVFIndex in ivf.rs correctly uses self.reader.io_parallelism(), which respects the configured IO parallelism of the underlying object store. The v2 IVFIndex doesn't have direct access to this value since its reader: FileReader doesn't expose io_parallelism().

Suggestion: either store the io_parallelism value during construction, or at minimum extract 8 into a named constant with a comment explaining why. As-is, this could be suboptimal on high-parallelism setups (e.g., cloud object stores) or too aggressive on single-disk systems.


Tests look solid — they verify the full lifecycle (prewarm causes IO, subsequent queries don't, second prewarm is a no-op). Everything else looks good.

@wjones127
wjones127 marked this pull request as ready for review March 4, 2026 00:39
@LuQQiu
LuQQiu merged commit cb757b2 into lance-format:main Mar 4, 2026
28 checks passed
@codecov

codecov Bot commented Mar 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

wjones127 added a commit to wjones127/lance that referenced this pull request Mar 4, 2026
Calling prewarm on IVF indices will now load the sub index partitions
into the cache.

Related to lance-format#3698
Xuanwo pushed a commit that referenced this pull request Nov 30, 2026
…m test (#11629)

Closes #6745.

## Summary

Most of #6745 had already been done by earlier PRs. This PR adds no new
codec or serialization logic. It only extends test coverage to the two
IVF+HNSW variants that weren't tested yet.

The issue asked for two things. Both were already on `main`:

1. **Zero-copy Arrow IPC serde for HNSW cache entries.** HNSW partitions
go through the generic IVF `PartitionEntry<S, Q>` codecs in
`rust/lance/src/index/vector/ivf/partition_serde.rs`. Those write the
sub-index with `write_ipc(index.to_batch())` and read it back through
`HNSW::load`. Since #6798, `HNSW::load` keeps the Arrow batch and serves
neighbor lists zero-copy (`LoadedHnswGraph`). `to_batch()` hands that
batch back unchanged, so a loaded graph round-trips through the cache
without being rebuilt.
2. **A test showing that, after prewarm, a serializing backend serves
HNSW queries with no IO.**
`test_prewarm_and_query_with_serializing_backend` prewarms through
`SerializingCacheBackend`, restarts the backend so only serialized
entries survive, queries, checks recall, and asserts `read_iops == 0`.
It already covered IVF_HNSW_SQ and IVF_HNSW_RQ.

Earlier PRs that did the work:

- #6090: prewarm for IVF indices and the no-IO assertion
- #6223: `CacheCodec` and the IVF partition codecs, which are generic
over the sub-index
- #6798: zero-copy HNSW loading
- #8136: the IVF_HNSW_SQ case
- #10522: the IVF_HNSW_RQ case

## Changes

Adds `ivf_hnsw_pq` (`PartitionEntry<HNSW, ProductQuantizer>`) and
`ivf_hnsw_flat` (`PartitionEntry<HNSW, FlatQuantizer>`) cases to
`test_prewarm_and_query_with_serializing_backend`. Every IVF+HNSW
variant is now covered by the prewarm, restart and no-IO check.

## Testing

- `cargo test --profile ci -p lance --lib
test_prewarm_and_query_with_serializing_backend`: all 5 cases pass
(`ivf_pq`, `ivf_hnsw_sq`, `ivf_hnsw_rq`, and the new `ivf_hnsw_pq` and
`ivf_hnsw_flat`) in 1.55s.
- `cargo fmt --all -- --check`: clean.
- `cargo clippy --profile ci -p lance --tests --benches -- -D warnings`:
clean. Clippy was run on the touched crate only, not with `--all`.

---
_Generated by [Claude Code](https://claude.ai/code)_

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants