add bloom filter pre-screen for external-internal id mapping - #3
Open
Seth Ockerman (OckermanSethGVSU) wants to merge 1 commit into
Open
add bloom filter pre-screen for external-internal id mapping#3Seth Ockerman (OckermanSethGVSU) wants to merge 1 commit into
Seth Ockerman (OckermanSethGVSU) wants to merge 1 commit into
Conversation
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 this does
Adds a blocked Bloom filter in front of
PointMappingsexternal → internal ID lookups.When Qdrant processes an update,
SegmentHolder::find_points_to_update_and_deletechecks each segment for the point. WithSsegments, an existing point usually produces one hit andS - 1misses, while a new point misses in every segment.Those misses currently require walking a
BTreeMap. The Bloom filter provides a cheap pre-check so most missing IDs can be rejected before touching the tree.The
BTreeMapis still the source of truth. A Bloom-filter hit only means "maybe present," so the normal lookup still runs. A miss means the ID is definitely absent.The implementation uses the same split-block approach as Impala/Parquet. Each lookup touches a single small block, keeping the check cache-friendly.
Deletes and persistence
The filter tracks IDs that have ever been inserted, so deleted IDs may leave stale bits behind. This is safe: stale bits can only cause false positives, which fall through to the
BTreeMapand return the correct result. Bits are never cleared, so the filter cannot introduce false negatives.The filter is not persisted and does not change the on-disk format. On restart,
PointMappingsis rebuilt from the existing change log throughset_link, which rebuilds the filter as part of normal recovery.The filter starts small and grows as needed. Rebuilds are sized with extra headroom and also remove stale bits left by deleted points.
Measurements
End-to-end release build, whole server, 8M points:
The benefit depends heavily on ID locality. Sequential updates already walk nearby
BTreeMapentries that tend to stay cached, so there is little to gain. Scattered IDs cause more random tree lookups and benefit much more.Microbenchmark at 1M points per segment, pinned to one core:
RAM overhead was about 2.1% at 1M points.
Turning it off
Set:
false,off, andnoalso work.A disabled filter allocates nothing and always falls through to the
BTreeMap, making it useful for A/B testing without deploying a different binary.Testing
The change has been tested against normal segment tests as well as randomized ID-tracker operation sequences covering numeric and UUID IDs, deletes, re-links, slot reuse, and deferred-point configurations.
I also tested recovery and lifecycle behavior against a real binary, including:
kill -9followed by WAL recoveryKnown limits