Repository navigation
Conversation
|
Hi @Xuanwo, when you have a moment, could you take a look at this one or point me to the right reviewer? It keeps the cached-partition |
SegmentPreFilter only consulted cached partition coverage when its base prefilter was empty. A scan that selects one index segment out of several builds a base restricted to that segment's fragments, so the base is never empty and every partition paid for a per-row filter even when all of its rows pass. When the base only removes deleted rows and rows outside the selected fragments, the segment's final mask is its ownership mask, so gate the fast path on only_deletions() instead of is_empty(). Closes lance-format#11166
0d1631a to
ba3e892
Compare
Xuanwo
left a comment
There was a problem hiding this comment.
I tested ba3e892b against cb8c25692. The segment-scoped queries returned the expected top-k with deleted and stale rows, with stable row IDs both enabled and disabled. SQL filters, external masks and fragment subsets also returned the expected rows.
On the same IVF_PQ fixture (100k rows per segment, 64 partitions, 16 probes, k=10), the clean warm median fell from 3.89 to 2.56 ms. With 1% uniformly deleted, it rose from 3.52 to 4.55 ms and cache usage grew by about 203 KB. Results matched across revisions. These timings come from one sequential comparison on a shared host.
When every probed partition contains a deletion, selects_all clones and subtracts the allow-list before falling through to masked top-k. Could you avoid that extra work while preserving the clean-partition gain, or run interleaved parent/head measurements to establish the tradeoff?
selects_all cloned the partition's row map and subtracted (or intersected) the mask just to test the result for emptiness. Vector search asks it for every probed partition, so a partition holding a deleted row paid for that copy before falling through to masked top-k. Add RowAddrTreeMap::is_subset and is_disjoint, which compare the maps in place, and use them in selects_all.
|
Thanks @Xuanwo, and thanks for the measurements. The extra work was in
I can't reproduce your 100k-row IVF_PQ setup on my machine, so I don't have new timings. Could you rerun the 1% deleted case against this head? If the remaining gap is from partition row IDs being loaded and cached for this check (about 203 KB in your run), I can look at gating |
There was a problem hiding this comment.
Verified the author’s allocation fix: the set predicates preserve the all-pass proof and remove its temporary-set allocations. All 133 selection tests and 15 focused vector regressions passed locally.
Deleted partitions still incur a coverage check and may occupy the coverage cache even when they cannot use NoFilter. The earlier timings were from the previous head and a sequential comparison, so the net latency trade-off after this fix remains unverified. Interleaved measurements would help decide whether coarser deletion gating is worthwhile.
Xuanwo
left a comment
There was a problem hiding this comment.
@vaibhavdabas16 I reran the 1% deletion comparison. All three revisions read the same rebuilt seeded fixture (100k rows per segment, 64 partitions, nprobes=16, k=10). I interleaved 360 warm measurements per revision per workload. Every partition in the deletion case had 7–28 deleted rows.
| Warm p50 | Baseline cb8c25692 |
Previous ba3e892b |
Revised 67ccbbbd |
|---|---|---|---|
| 1% deleted | 4.099 ms | 4.971 ms | 4.084 ms |
| Clean | 4.129 ms | 4.098 ms | 4.182 ms |
The revised head's paired median latency was 0.21% below baseline with deletions and 0.70% above baseline without them. The previous deletion regression reproduced and the revision addressed it on this fixture. The earlier clean speedup did not reproduce. Session cache usage remained 206,400 bytes above baseline with deletions and 203,106 bytes above baseline without them. The ordered top-k IDs and distance bits matched for every query. These results give me no reason to ask for another deletion check.
Start the allow-list range at the first probe fragment so an early rejection does not scan an unrelated mask prefix. Warm RowAddrMask::selects_all time per probe (two pinned physical cores, 30 interleaved trials per case per core, 124 probes per batch). Columns show the range of the two run medians on a Xeon Platinum 8488C. Probe main dense before seek with seek 16,924 fragments, all match (ms) 1.445-1.448 0.867-0.870 0.858-0.859 8,462 alternating, last reject (us) 753-758 467-469 461-462 8,462 upper half, first reject (ns) 47.2-47.6 10740-10870 53.0-53.1 128 spread, all match (us) 13.62-13.74 12.61-12.76 15.09-15.13 The allow list contained 16,924 partial fragment bitmaps with physical rows 0..1024. Each probed fragment had four valid offsets. The rejection cases also probed offset 1024. All three variants agreed on all 1,364 individual probe results per run. These timings cover the predicate. Measured baseline cb512b6 contains lance-format#11250. The subsequent main commit 0944680 touches MemWAL only. The two measured source files match the rebased revisions byte for byte.
Closes #11166.
Problem
SegmentPreFilteronly checks cached partition row coverage when its base prefilteris_empty(). When a scan selects one segment out of several,DatasetPreFilterrestricts the base to that segment'sfragment_bitmap. The base is then never empty, so IVF hands HNSW the per-row filter, even for partitions where every row passes.Fix
Gate
needs_partition_row_ids/is_empty_foronbase.only_deletions()instead ofbase.is_empty(). With a deletions-only base,wait_for_readyalready sets the segment's final mask to the ownership mask (the base selects every live row of the selected fragments), soownership_mask.selects_all(rows)provesNoFilteris equivalent. A user filter, an overlay block, or FTS fragment pruning still disables the fast path, which the existingordinary_segmentassertion covers.Tests
Extended
test_append_only_deltas_keep_empty_prefilter_fast_pathwith the single-segment case. The base built from only the old segment is non-empty, the old segment's partition still takes the fast path, and rows of fragments outside the segment are still filtered.Note: I couldn't run the
lancecrate tests or clippy locally (the test build runs out of memory on my machine).cargo fmtandtypospass. I'm relying on CI here and will fix anything it flags.