Repository navigation
Deferred threshold integration - #8246
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/segment/src/segment/segment_ops.rs`:
- Around line 665-689: The current logic bails out early if
self.deferred_internal_id.is_none(), preventing recomputation when new writes
push vectors past deferred_threshold; change the condition to only skip when
!self.is_appendable() || self.config().vector_data.is_empty() so the code always
recomputes from deferred_threshold when possible. In the deferred_threshold
branch, compute deferred_id by iterating self.vector_data.values() and calling
vector_data.vector_storage.borrow().get_deferred_id(deferred_threshold), then if
a valid min deferred_id exists and (deferred_id as usize) <
self.total_point_count() set self.deferred_internal_id = Some(deferred_id) else
set self.deferred_internal_id = None to clear stale cache values.
In `@lib/segment/src/vector_storage/vector_storage_base.rs`:
- Around line 214-221: The get_deferred_id implementation currently uses floor
division (deferred_threshold / size_per_vector) which underestimates the first
crossing offset for non-multiples; change to ceiling division so any leftover
bytes push to the next vector. Replace the computation of deferred_id in
get_deferred_id to use ceil(div) logic (e.g. (deferred_threshold +
size_per_vector - 1) / size_per_vector or equivalent safe integer math), then
clamp the result with .min(self.total_vector_count()) and cast to
PointOffsetType as before; reference get_deferred_id, deferred_threshold,
size_per_vector, deferred_id, and total_vector_count.
- Around line 268-287: The early-return is using an off-by-one index and thus
short-circuits incorrectly: change the precheck call from
self.inner_vectors_count_up_to(total as PointOffsetType - 1) to
self.inner_vectors_count_up_to(total as PointOffsetType) so the cumulative bytes
are computed for the full range, and keep the comparison against
deferred_threshold (>=) to return total when the total cumulative bytes meet or
exceed the threshold; ensure the rest of the binary search still searches [0,
total) using inner_vectors_count_up_to(mid as PointOffsetType) and returns
Some(lo as PointOffsetType) as before.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (43)
lib/collection/src/collection_manager/fixtures.rslib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rslib/collection/src/collection_manager/optimizers/indexing_optimizer.rslib/collection/src/collection_manager/optimizers/merge_optimizer.rslib/collection/src/collection_manager/optimizers/vacuum_optimizer.rslib/collection/src/optimizers_builder.rslib/collection/src/shards/local_shard/mod.rslib/collection/src/shards/local_shard/snapshot.rslib/collection/src/shards/local_shard/snapshot_tests.rslib/collection/src/tests/mod.rslib/collection/src/update_workers/optimization_worker.rslib/edge/src/lib.rslib/segment/benches/multi_vector_search.rslib/segment/src/index/struct_payload_index.rslib/segment/src/segment/entry.rslib/segment/src/segment/mod.rslib/segment/src/segment/segment_ops.rslib/segment/src/segment/tests.rslib/segment/src/segment_constructor/segment_builder.rslib/segment/src/segment_constructor/segment_constructor_base.rslib/segment/src/segment_constructor/simple_segment_constructor.rslib/segment/src/vector_storage/multi_dense/appendable_mmap_multi_dense_vector_storage.rslib/segment/src/vector_storage/multi_dense/simple_multi_dense_vector_storage.rslib/segment/src/vector_storage/multi_dense/volatile_multi_dense_vector_storage.rslib/segment/src/vector_storage/vector_storage_base.rslib/segment/tests/integration/byte_storage_hnsw_test.rslib/segment/tests/integration/byte_storage_quantization_test.rslib/segment/tests/integration/fixtures/segment.rslib/segment/tests/integration/multivector_filtrable_hnsw_test.rslib/segment/tests/integration/multivector_quantization_test.rslib/segment/tests/integration/payload_index_test.rslib/segment/tests/integration/segment_builder_test.rslib/segment/tests/integration/segment_on_disk_snapshot.rslib/segment/tests/integration/segment_tests.rslib/segment/tests/integration/sparse_discover_test.rslib/segment/tests/integration/sparse_vector_index_search_tests.rslib/shard/src/operations/optimization.rslib/shard/src/optimize.rslib/shard/src/optimizers/indexing_optimizer.rslib/shard/src/optimizers/segment_optimizer.rslib/shard/src/segment_holder/mod.rslib/shard/src/segment_holder/snapshot.rslib/shard/src/segment_holder/tests.rs
IvanPleshkov
commented
Feb 27, 2026
IvanPleshkov
marked this pull request as draft
February 27, 2026 10:47
IvanPleshkov
commented
Feb 27, 2026
IvanPleshkov
marked this pull request as ready for review
February 27, 2026 16:45
generall
self-requested a review
February 27, 2026 18:32
generall
approved these changes
Feb 27, 2026
JojiiOfficial
approved these changes
Mar 2, 2026
agourlay
approved these changes
Mar 2, 2026
This was referenced Mar 3, 2026
This was referenced Mar 11, 2026
generall
pushed a commit
that referenced
this pull request
Mar 26, 2026
* Deferred threshold integration * update deferred id * apply update_deferred_internal_id * fix segment inspector * use avaliable bytes count * renamings * review remarks * review remarks * move has_deferred_points * remove todo * update comments
KShivendu
pushed a commit
that referenced
this pull request
Mar 30, 2026
* Deferred threshold integration * update deferred id * apply update_deferred_internal_id * fix segment inspector * use avaliable bytes count * renamings * review remarks * review remarks * move has_deferred_points * remove todo * update comments
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.
Summary
This PR introduces a deferred threshold for segments with a deferred internal id.
Part of the deferred points feature, described here:
https://www.notion.so/qdrant/Deferred-points-in-appendable-segments-311674779d33808a9e97f9449267b2f6
Changes list
This PR adds two new fields into
Segmentstruct:deferred_points_threshold_bytesis presented in each segment, including indexed ones; it's just a propagation data from the collection - the value isSomeifprevent_unoptimized = trueandindexing_threshold > 0.Segment owns the logic of deferred points and decided himself if he has deferred points inside.
On the segment level, we disable the deferred points feature in case when:
The segment decides that he has deferred points, he sets
Somefordeferred_internal_id, which describes the start internal ID to filter in read operations (includingdeferred_internal_id).PR has a function
update_deferred_internal_id(). It computes the deferred ID from vector storage layout sizes, taking the minimum across all non-multivector data. Called on segment creation/load and after each point insertion (put_all_vectors, upsert_vector, insert).has_deferred_points()— quick check used by the indexing optimizer to trigger optimization on segments that have deferred points, ensuring they get indexed promptly.Threshold derived from config — get_deferred_points_threshold_bytes() on OptimizersConfig returns Some(indexing_threshold_kb * 1024) when prevent_unoptimized == true, None otherwise.
All callers updated — every call site for build_segment, load_segment, SegmentBuilder::build, proxy_all_segments, and snapshot_all_segments now passes the threshold (mostly None in tests/edge).
Future work
For simpler review, multivectors and sparse vectors will be applied in the next changes of this milestone (it's marked in the design document plan).