Conversation
Reuse the prewarm byte-window reader for query-time partition loads. Uncached nprobes in a prepare chunk are grouped by encoded size and read in one Range/Ranges decoder invocation, so adjacent partitions share large sequential I/O and scattered probes share page-metadata scheduling instead of one read_stream per partition. Keep the prepare-window memory bound: search still streams chunks of prepare_parallelism partitions and scores them in the existing global-top-k and streaming batches. Co-authored-by: Yang Cen <BubbleCal@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the performance issue?
PR #9049 made IVF prewarm 30x faster by reading adjacent partitions in 64 MiB windows instead of one
read_streamper partition. Query-time loading was left on the old per-partition path. A cold search still issues a decoder setup, page-metadata init, and object-store GET round for every probed partition.Query nprobes are usually scattered, so a naive copy of prewarm's contiguous windows would almost never fire. The I/O scheduler only coalesces ranges that arrive in the same
submit_request, so concurrent single-partition reads do not merge even when pages are nearby.How does this PR improve performance?
Reuse the prewarm reader for query-time loads:
prepare_parallelism, typically the CPU pool size) are sorted and grouped by the same encoded-byte / partition caps as prewarm (LANCE_IVF_PREWARM_WINDOW_SIZE_BYTES, default 64 MiB).Range. Scattered nprobes use oneRangesrequest so page-metadata init and nearby GETs can coalesce.nprobes.load_partition(single ID) is unchanged forsearch_in_partitionand other one-partition callers.HF retrieval benchmarks (open-index excluded)
4 vCPU / 15 GiB, local disk,
pylance 13.0.0-beta.4. Cosine IVF_RQ, no refine,k=100.Protocol (cold sample): open the dataset and call
get_ivf_model/centroidsoutside the timer (this is 8 IOPS / ~4 MiB).posix_fadvise(DONTNEED)on_indicesonly. Reset I/O counters. Time one search on that already-open handle. FreshSessionper cold sample so the partition cache is empty. Warm = one session, 5 untimed queries, then measure.windowedis the default 64 MiB grouper.singletonsetsLANCE_IVF_PREWARM_WINDOW_SIZE_BYTES=1(same new reader, one partition per group).Build (centroids reused for RQ5):
MS MARCO (8.8M × 1024-d, 20 queries)
Coyo-VE (15.4M × 2048-d, 15 queries)
What this shows
index.idx+auxiliary.idx.Tests
test_plan_query_load_groups_*andtest_selected_partition_row_span_*cover sparse grouping, byte/partition caps, and contiguous vs gapped row spans.test_query_partition_load_uses_windowed_iobuilds a 16-partition IVF_PQ index, compares grouped-load IOPS to a single-partition load (must be a small multiple, not N×), checks concurrentload_partitionsdoes not deadlock, and asserts a follow-up query issues zero I/O.test_global_topk_search_bounds_in_flight_prepared_partitionsstill pass.Lint:
cargo fmt --allandcargo clippy -p lance --tests --benches -- -D warningspassed. Full-workspace clippy was not rerun; onlyrust/lance/src/index/vector/ivf/v2.rschanged.cargo test -p lance --lib -- index::vector::ivf::v2::: 116 passed.