Skip to content

perf(index): size BloomFilter zones without serializing and skip the copy on remapped load - #10750

Merged
Xuanwo merged 8 commits into
lance-format:mainfrom
LuciferYang:perf/bloomfilter-hotpaths
Nov 12, 2026
Merged

Xuanwo merged 8 commits into
lance-format:mainfrom
LuciferYang:perf/bloomfilter-hotpaths

Conversation

@LuciferYang

@LuciferYang LuciferYang commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #10744.

Deep size now uses Sbbf::size_bytes(), which returns the same number as to_bytes().len() without building the bytes. The internal loader returns the index by value, so load_with_remapping sets the remapper on it directly, and load wraps it in an Arc as before.

The author measured on a release build on an Apple M2 Max, an index with 2000 zones, median of 7 runs: deep_size_of goes from 4554 µs to 3 µs. The removed copy took 1921 µs and allocated a second copy of the 65.6 MB of filters. These figures are author-reported and were not independently reproduced here.

How was this patch tested

test_bloomfilter_deep_size_equals_serialized_payload checks that an index's deep size is its struct sizes plus each zone's serialized filter size. This PR does not change that value, so the test pins the result and not the speed. The existing fragment reuse contract tests for BloomFilter with tagged histories go through load_with_remapping.

On the head merged with main at e91343d: cargo fmt --all -- --check and the full workspace cargo clippy --profile ci --all --tests --benches -- -D warnings pass. The 22 lance-index BloomFilter tests and the BloomFilter cases of scalar_queries_translate_deleted_sources_and_lazy_blocks and legacy_scalar_lifecycle_never_enters_new_reader pass on that head. Sbbf::test_serialization (size_bytes equals to_bytes().len()) was verified on the same unchanged lance-core inputs and is unaffected by the main advances.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer performance labels Nov 5, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 5, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 2026
Xuanwo added a commit that referenced this pull request Nov 12, 2026
Main's `ci` profile lint fails with `clippy::undocumented_unsafe_blocks`
at
`DictionaryDataBlock::gather_variable_width_typed` (`data.rs:1200`),
which blocks the full Rust
lint for every PR in the workspace, #10750 included.

The existing `SAFETY:` note sits inside the outer unsafe block, so it
justifies the unchecked
offset reads but leaves the block itself undocumented. This moves the
justification above the
block and extends it to cover the rest of it: the index/offset bounds
proven by
`validate_offsets_for_append` and the first pass, `total_bytes` fitting
both `usize` and `T`, the
two output allocations being disjoint from the dictionary data, and
every rebased offset and
payload byte being written before the `set_len` calls. Comment-only; no
runtime change.

Context: the block came in with #10911. Validation on this branch:
`cargo fmt --all -- --check`
and `cargo clippy --profile ci --all --tests --benches -- -D warnings`
both pass.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

No blocking issues found. The change preserves the existing size-accounting and remapping behavior.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. The patch replaces the serialized-size estimate with Sbbf::size_bytes() and removes the redundant filter copy on remapped load, and the fragment-reuse BloomFilter contract cases exercise the remapped path. On integration head 79ddcf4 the merge of main e91343d has no bloomfilter.rs overlap: all 13 workflows succeeded, 39 check runs succeeded and 5 skipped (skips are not counted as passes), and the workspace clippy plus the 22 BloomFilter and 4 fragment-reuse BloomFilter tests pass locally. The performance figures remain author-reported; no independent benchmark was run here. No blockers.

@Xuanwo
Xuanwo merged commit 38bb596 into lance-format:main Nov 12, 2026
44 checks passed
@LuciferYang

Copy link
Copy Markdown
Contributor Author

Thank you @Xuanwo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer K-approved Latest Gatekeeper recommendation permits acceptance. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: BloomFilter index serializes every filter to size itself and deep-copies all filters on remapped load

2 participants