Repository navigation
perf: cache the address-based deletion mask per dataset version - #10404
Conversation
Without stable row ids, every vector search rebuilds the dataset-wide deletion mask: it walks every fragment with a deletion file, converts each deletion vector into a bitmap and merges them. Deletion files of a version are immutable, so the result only depends on the version and the fragment set. The stable-row-id path already caches its mask under `RowAddrMaskKey`; the address path did not. Cache the address mask the same way, in the metadata cache, keyed by (version, manifest e-tag, fragment-set hash, restricted or not). As on the row-id path, a dataset without an e-tag is not cached, because a dataset recreated at the same URI restarts at the same version numbers. On a 6.8B-row table with 99,020 fragments (all with deletion files), 153 index segments and 10% rows deleted, this eliminates the ~35 s per-query mask reconstruction overhead; combined with lance-format#10403, steady-state k=10 search drops from 66 s to 0.37 s, versus 0.30 s on the same data files without deletions. Results are unchanged.
16e7f42 to
8206a9f
Compare
There was a problem hiding this comment.
Caching the immutable, version-scoped mask remains appropriate alongside #10403’s mask sharing, now in main.
The accepted capacity constraint remains: the metadata cache must retain the mask alongside other active metadata to avoid per-query reconstruction. The benchmark figures predate this integration; current-head latency has not been remeasured. No further change is requested.
Xuanwo
left a comment
There was a problem hiding this comment.
Approved. The address-based deletion mask is cached per version, manifest e-tag and fragment set, with the restricted/unrestricted discriminator; the strengthened tests cover cache hits, fragment-set and version separation, e-tag key isolation, and the restricted/unrestricted semantic difference. Local fmt, full ci-profile Clippy, the prefilter and affected segment-skip tests pass; applicable CI and Gatekeeper are green. The benchmark figures remain author-reported pre-integration evidence and the metadata-cache capacity caveat is documented in the description.
Part of #10402. #10403 is now in
main; this branch is merged with the currentmain.Problem
In
DatasetPreFilter::create_deletion_mask_impl(rust/lance/src/index/prefilter.rs), the stable-row-ID path caches its constructedRowAddrMaskindataset.metadata_cacheunderRowAddrMaskKey(keyed byversion,e_tag, and fragment-set hash).However, the default address-based path (
!manifest.uses_stable_row_ids()) rebuilds the dataset-wide deletion mask on every query: it loads every fragment'sDeletionVector, converts each into aRoaringBitmap, and merges them into aRowAddrTreeMap. Because deletion files for a committed dataset version are immutable, the resulting mask only depends on the dataset version and the target fragment set.Solution
fragment_set_hash(&RoaringBitmap) -> u64.dataset.manifest_location().e_tagis present, cache the address-basedRowAddrMaskindataset.metadata_cacheunderRowAddrMaskKey:version:dataset.manifest().versione_tag:Some(e_tag.as_str())restrict_hash:Some((fragment_set_hash(&fragments) << 1) | restrict_to_fragments as u64)(bit 0 separates the restricted allow-list from the unrestricted block-list over the same fragment set).e_tagisNone.Benchmark
Measurement boundary: these numbers are the author's pre-integration measurements. They are problem evidence, not a benchmark of the current head; this branch has not re-measured them.
Steady-state
k=10latency on the same 6.8B-row dataset (99,020fragments,153IVF segments; see #10402):mainnprobes=1nprobes=32nprobes=1All benchmark runs used
metadata_cache_size_bytes=48 GiBandindex_cache_size_bytes=96 GiBso steady-state numbers measure CPU overhead only.The cached mask takes ~1.4 GB in
metadata_cachefor 790M deleted rows (~1.8 bytes per deleted row, tracked viaDeepSizeOf). BecauseDEFAULT_METADATA_CACHE_SIZEis 1 GiB (~0.97 GiB single-shard admission limit inQuickCacheBackend), the default cache budget accommodates masks up to roughly 500M deleted rows out of the box; workloads with more than ~500M deleted rows should configure a largermetadata_cache_size_bytesto retain the mask.Tests
test_address_deletion_mask_cached_per_version(index/prefilter.rs): verifies cache hits, narrower-fragment and newer-version entries, distinguishes restricted from unrestricted masks with a live row outside the requested fragment set, and checks that a changed e-tag at the same version gets a separate entry. The e-tag case is focused cache-key isolation evidence, not a recreated-dataset I/O experiment.test_deletion_mask_recreated_at_same_uriandtest_deletion_mask_without_generation_token_is_not_cachedoveruse_stable_row_id in [false, true]. The local-filesystem recreation case has no e-tag, so it covers mask semantics without exercising cache-enabled generation isolation.