Repository navigation
Conversation
JingsongLi
left a comment
There was a problem hiding this comment.
The budgeted partition cache from #122 already serves repeated probes with zero payload reads in the baseline. Please consider storing cosine norms in that cache and counting them against the same budget. A benchmark against the baseline with identical reader options would show the effect of the norm cache and the AVX2 kernel.
| .observation | ||
| .record_ivf(&probe_indices, 0, &self.list_counts); | ||
| let mut heap = ReaderTopKHeap::new(k); | ||
| if let Some(lists) = &self.resident_lists { |
There was a problem hiding this comment.
[P1] Preserve Top-K tie behavior for resident lists
This branch pushes every candidate into one heap and bypasses the existing parallel list scans and ordered merge of list-local heaps. With two cosine lists of 32,768 rows at 16 dimensions, k=2, and nprobe=2, the baseline returned IDs [32769, 1] and this branch returned [32769, 32768], with distances [0.0, 1.0] in both runs. Please reuse the existing probe grouping and heap merge for resident lists and cover a tie at the cutoff above the parallel-scan threshold.
There was a problem hiding this comment.
Updated in 298ac84. Cached lists now go through the existing probe grouping, list-local heaps and ordered merge. A regression compares cached and uncached IDs and distances on two 32,768-row cosine lists at d=16 and k=2, with a tie at the cutoff.
| )); | ||
| } | ||
|
|
||
| self.ensure_resident_lists()?; |
There was a problem hiding this comment.
[P1] Keep unprobed lists off the query's required read path
This call reads the entire shard one list at a time before selecting the probes. With 128 nonempty lists and nprobe=8, the first query after metadata initialization went from one pread call to 128. When the final, unprobed list had a storage read error, the baseline returned results and this branch failed the search. Please keep normal queries on the existing read path for the selected probes and use bounded multi-range reads for any explicit full-shard warmup.
There was a problem hiding this comment.
Removed full-shard warmup in 298ac84. Probe selection now precedes list reads as it does on main. Cache misses use the existing bounded multi-range reads, so an unprobed list is outside the query's read path.
| } | ||
| // The full resident and partition cache share one reader budget. | ||
| // Release any previously cached partitions before retaining the shard. | ||
| self.list_cache = None; |
There was a problem hiding this comment.
[P2] Share cached lists with batch and range search
Dropping the FIFO here leaves read_scan_lists without a cache for batch Top-K and range search. After a single query warmed the same reader, the baseline served both operations with zero list reads, while this branch reread eight lists on every call in the same test. Please serve resident entries through read_scan_lists so all three search paths can share the cached payloads and cache accounting.
There was a problem hiding this comment.
The revised implementation retains the existing FIFO and populates norms on admission to read_scan_lists. All three search modes continue to share its entries and byte budget. Range search keeps its existing cosine input validation.
| let mut heap = ReaderTopKHeap::new(k); | ||
| if let Some(lists) = &self.resident_lists { | ||
| for list_id in probe_indices { | ||
| scan_flat_list(&q, &lists[list_id], self.d, self.metric, filter, &mut heap)?; |
There was a problem hiding this comment.
[P2] Validate resident entries against public reader metadata
Rust callers can edit the public list metadata through VectorIndexReader::IvfFlat. After warming the reader and redirecting list_offsets[0] to another valid list of the same shape, the baseline returned IDs from the new offset and this path returned stale IDs. Please validate the offset, count, encoded ID length, and dimension before reusing a resident list, as the FIFO does.
There was a problem hiding this comment.
The separate resident entries were removed. Every cache lookup now goes through the FIFO's existing offset, count, ID-length and dimension checks, and a changed entry's norms are evicted with its payload.
| data.truncate(data.len() - 1); | ||
| let mut reader = IVFFlatIndexReader::open(Cursor::new(data)).unwrap(); | ||
| reader.set_resident_memory_budget(1024 * 1024); | ||
| assert!(reader.search(&vec![1.0; 7], 5, 4).is_err()); |
There was a problem hiding this comment.
[P2] Pass the CI Clippy check
Both uses of &vec![1.0; 7] in this test trigger clippy::useless_vec under -D warnings. Please use &[1.0; 7] at both call sites.
There was a problem hiding this comment.
The full-shard cache tests containing those two allocations were removed along with that implementation. The replacement cutoff test uses a stack array. The updated core, tests and benchmark targets compiled locally.
e63280d to
298ac84
Compare
|
I revised the patch around #122's probed-list FIFO and added an |
|
Benchmark run · success · attempt 2 Vector index benchmark🟢 No alerts (6/6 indexes)
🟡 QPS ↓ >10% or Recall ↓ >1pp · 🔴 QPS ↓ >20% or Recall ↓ >3pp. Advisory only; QPS is measured after warmup. Absolute metrics & environmentMedians, base → PR. QPS is timed after warmup; P95 uses the first warm sweep.
Base |
JingsongLi
left a comment
There was a problem hiding this comment.
I verified the fixes for the five previous findings on 298ac84.
| && !list.ids.is_empty() | ||
| && list | ||
| .retained_bytes() | ||
| .saturating_add(list.ids.len().saturating_mul(size_of::<f32>())) |
There was a problem hiding this comment.
[P2] Keep hot posting lists in the FIFO when caching cosine norms
The shared cache-miss path computes a norm for every row. Batch search still computes norms during the scan, and range search computes them as part of input validation. With a 16 MiB reader budget and four 128-dimensional lists of 8,010 rows, repeated batch-only and range-only queries went from zero list reads on main to rereading one approximately 3.9 MiB list per call. Please prioritize retaining the decoded lists and cache norms only for scans that reuse them, when the remaining budget can hold both.
There was a problem hiding this comment.
Updated in 89facfd. Batch and range scans now load only the decoded posting lists. Single-query cosine top-K can add norms after the decoded payloads have been admitted, using only the remaining cache budget. On later misses the cache releases optional norms before evicting a posting list. The new tight-budget regression warms a single-query entry, then checks that repeated batch and range scans avoid rereading the lists; it also checks that batch and range scans on a fresh cache never allocate norms.
The library, test and benchmark targets compile locally. Both the CI and PR benchmark workflows are waiting for workflow approval on 89facfd. Could a maintainer approve the runs so we can verify the tests and compare recall and QPS?
| peak_rss_bytes: peak_resident_set_bytes()?, | ||
| }; | ||
| run_built_index(&config, &dataset, &ground_truth, &built)?; | ||
| run_built_index(&config, &dataset, ground_truth(built.name), &built)?; |
There was a problem hiding this comment.
[P2] Validate the metric of a reused benchmark index
With ANN_REUSE_INDEX_PATH, search uses the metric stored in the file and ground truth uses the metric selected by ANN_INDEXES. In a small fixture, swapping same-dimension L2 and cosine IVF-FLAT files still produced a successful run and printed the selected case label, but recall dropped from 1 to 0. Please check the file's metric against the selected case before computing recall.
There was a problem hiding this comment.
Fixed in 89facfd. ANN_REUSE_INDEX_PATH now reads the persisted index metadata and validates its metric, index type and dimension against the selected benchmark case before computing ground truth. The regression writes an L2 and a cosine IVF-FLAT index of the same dimension and checks both directions of the mismatch.
| const ALL_INDEX_NAMES: [&str; 5] = ["IVF_FLAT", "IVF_SQ", "IVF_PQ", "IVF_RQ", "DISKANN"]; | ||
| const ALL_INDEX_NAMES: [&str; 6] = [ | ||
| "IVF_FLAT", | ||
| "IVF_FLAT_COSINE", |
There was a problem hiding this comment.
[P2] Make the public-data cosine benchmark opt-in
The documented public-data command leaves ANN_INDEXES unset. Adding IVF_FLAT_COSINE to the default set adds an index build and a full cosine ground-truth sweep even when the command supplies the published L2 ground truth. On GIST1M with 1,000 queries, that is one billion extra 960-dimensional cosine scores. Please make cosine an explicit selection for manual runs. The PR comparison already selects this case explicitly.
There was a problem hiding this comment.
Changed in 89facfd. With ANN_INDEXES unset or set to all, the public benchmark still runs the original five L2 cases. The extra cosine index build and exact cosine ground-truth pass require an explicit IVF_FLAT_COSINE selection. The PR benchmark selects it explicitly, and the selection test covers both defaults.
Store vector norms alongside decoded entries in the shared FIFO and charge them to the reader budget. Reuse those norms for cosine Top-K, including a four-candidate AVX2 kernel, while retaining the existing I/O, metadata validation and parallel heap merge. Cover ties at the parallel cutoff and compare warm IVF-FLAT cosine search against the base revision in the PR benchmark. Cache cosine norms for single-query scans only, using spare FIFO space. Reclaim optional norms before decoded lists. Validate reused benchmark indexes and require explicit selection of the cosine case. Co-Authored-By: Codex <noreply@openai.com> AI-Model: gpt-6 AI-Contributed/Feature: 284/284 AI-Contributed/UT: 43/43
298ac84 to
89facfd
Compare
Closes #136.
Keep vector norms in the existing decoded-list FIFO for probed IVF-FLAT cosine lists, charging their allocation to the same reader budget. Single-query, batch and range searches continue to use the same cache, metadata validation and bounded reads. Unfiltered Top-K can reuse query loads across four candidates on AVX2.
The regression compares cold and warm results to uncached search with two 32,768-row lists and a tie at the parallel cutoff. The PR comparison benchmark now includes IVF_FLAT_COSINE and uses the same driver, dataset, reader budget and probe count on base and candidate. Local validation compiled the core crate, tests and benchmark targets. Execution is left to upstream CI.