Repository navigation
Immutable storage for mmap numeric index - #8594
Conversation
b900efe to
2a8df87
Compare
| let hw_counter = HardwareCounterCell::new(); | ||
| // No deletions in this test — sized to comfortably exceed the | ||
| // stored deletion bitslice for the few points added below. | ||
| let deleted_points = BitVec::repeat(false, 64); |
There was a problem hiding this comment.
Can we also test with a bitset that is too small? I don't see it here, at least not in the diff.
9676ac8 to
8c369a8
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/index/field_index/numeric_index/mmap_numeric_index.rs`:
- Line 2: The code currently resizes the in-memory deleted_points mask using
true which incorrectly treats missing external bits as deleted; change the
resize call on deleted_points to use false so missing bits default to live, then
OR the persisted deleted.bin mask into deleted_points (i.e., keep the existing
OR logic but ensure absent external bits are false before ORing). Update the
logic around deleted_points and the external/persisted deleted mask handling so
you first ensure deleted_points.resize(..., false) and only then bitwise-OR the
persisted deleted.bin mask into deleted_points.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f189d5b0-4b7a-40f3-a354-9392c1125044
📒 Files selected for processing (7)
lib/segment/benches/numeric_index_check_values.rslib/segment/src/index/field_index/index_selector.rslib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rslib/segment/src/index/field_index/numeric_index/mod.rslib/segment/src/index/field_index/numeric_index/tests.rslib/segment/src/index/query_optimization/rescore_formula/value_retriever.rslib/segment/src/index/struct_payload_index.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- lib/segment/benches/numeric_index_check_values.rs
- lib/segment/src/index/field_index/index_selector.rs
8c369a8 to
63c2a5d
Compare
63c2a5d to
b311b43
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThreads an explicit deletion mask ( Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (1)
204-217: Worth a brief doc note:deleted.binis build-time only.After this PR,
deleted.binis only written duringbuild()(capturing points whose values are empty) and is never updated byremove_pointor a flusher. Listing it inimmutable_files()and makingflusher()a no-op is correct for that model, but it's a non-obvious semantic shift from the previous writable deletion bitmap. A one-line comment aboveflusher(or onStorage.deleted) documenting that runtime deletions live only in the in-memorydeleted: BitVec(authoritative source on reopen is the external&BitSlice) would prevent future surprises.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs` around lines 204 - 217, The review notes that deleted.bin is now build-time only and runtime deletions live in the in-memory deleted BitVec (authoritative on reopen is the external &BitSlice), so add a one-line doc comment explaining this semantic shift: above the flusher() method (function flusher) or on the Storage.deleted field, state that deleted.bin is written only during build() and not updated at runtime, that remove_point updates the in-memory deleted: BitVec only, and that immutable_files() intentionally lists deleted.bin while flusher() is a no-op; include references to deleted.bin, flusher(), immutable_files(), Storage.deleted, BitVec and &BitSlice to make the behavior explicit for future maintainers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs`:
- Around line 204-217: The review notes that deleted.bin is now build-time only
and runtime deletions live in the in-memory deleted BitVec (authoritative on
reopen is the external &BitSlice), so add a one-line doc comment explaining this
semantic shift: above the flusher() method (function flusher) or on the
Storage.deleted field, state that deleted.bin is written only during build() and
not updated at runtime, that remove_point updates the in-memory deleted: BitVec
only, and that immutable_files() intentionally lists deleted.bin while flusher()
is a no-op; include references to deleted.bin, flusher(), immutable_files(),
Storage.deleted, BitVec and &BitSlice to make the behavior explicit for future
maintainers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d500bf4f-cacb-4a2b-bf40-cb6292a4e4f4
📒 Files selected for processing (7)
lib/segment/benches/numeric_index_check_values.rslib/segment/src/index/field_index/index_selector.rslib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rslib/segment/src/index/field_index/numeric_index/mod.rslib/segment/src/index/field_index/numeric_index/tests.rslib/segment/src/index/query_optimization/rescore_formula/value_retriever.rslib/segment/src/index/struct_payload_index.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- lib/segment/benches/numeric_index_check_values.rs
- lib/segment/src/index/query_optimization/rescore_formula/value_retriever.rs
There was a problem hiding this comment.
♻️ Duplicate comments (1)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (1)
173-181:⚠️ Potential issue | 🔴 CriticalDefault missing external deletion bits to live.
Line 180 still resizes a shorter
deleted_pointsmask withtrue, so any point beyond the external mask length is treated as deleted beforedeleted.binis ORed in. Missing id-tracker bits should default tofalse; otherwise live points can disappear after reload.🐛 Proposed fix
- deleted.resize(point_to_values.len(), true); + deleted.resize(point_to_values.len(), false); deleted.bitor_assign(deleted_payloads_bitslice.as_ref());🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs` around lines 173 - 181, The code currently expands the in-memory deleted mask `deleted` using deleted.resize(point_to_values.len(), true), which treats missing id-tracker bits as deleted; change this to default missing bits to live by resizing with false (e.g., call deleted.resize(point_to_values.len(), false)) before OR-ing with the external `MmapBitSlice` (`deleted_payload_mmap.read_all()` and subsequent deleted.bitor_assign(...)) so points beyond the external mask are considered live until marked deleted by `deleted.bin`; ensure references remain to `deleted_points`, `point_to_values`, `MmapBitSlice`, `deleted.resize`, and `deleted.bitor_assign`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs`:
- Around line 173-181: The code currently expands the in-memory deleted mask
`deleted` using deleted.resize(point_to_values.len(), true), which treats
missing id-tracker bits as deleted; change this to default missing bits to live
by resizing with false (e.g., call deleted.resize(point_to_values.len(), false))
before OR-ing with the external `MmapBitSlice`
(`deleted_payload_mmap.read_all()` and subsequent deleted.bitor_assign(...)) so
points beyond the external mask are considered live until marked deleted by
`deleted.bin`; ensure references remain to `deleted_points`, `point_to_values`,
`MmapBitSlice`, `deleted.resize`, and `deleted.bitor_assign`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 252d0247-f708-4f82-9d5f-856293a9d596
📒 Files selected for processing (4)
lib/common/common/src/universal_io/wrappers/typed.rslib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rslib/segment/src/index/field_index/numeric_index/mod.rslib/segment/src/index/field_index/stored_point_to_values.rs
✅ Files skipped from review due to trivial changes (1)
- lib/common/common/src/universal_io/wrappers/typed.rs
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (1)
236-238: Document the in-memory-only deletion contract on the public API.
flusher()is a no-op andremove_point()mutates only the in-memorydeletedBitVec — a substantial contract change from the previous mmap-backed deletion storage. The expectation is now that callers must re-supply deletions via the&BitSliceargument toopen()(typicallyid_tracker.deleted_point_bitslice()); without that, runtime deletions made viaremove_pointare lost on reload.This invariant is currently only documented inside a test comment (
tests.rs:665-670). A reader ofMmapNumericIndexin isolation will incorrectly assumeflusherpersists deletions. Please add a brief doc comment on both methods (and ideally on the struct itself) so callers outside the segment integration path don't get caught out.📝 Suggested doc comments
+ /// Returns a no-op flusher. + /// + /// Deletions made via [`Self::remove_point`] are kept only in memory; they + /// are not persisted to `deleted.bin`. The authoritative deletion state is + /// re-supplied via the `deleted_points: &BitSlice` argument to + /// [`Self::open`] (typically the id-tracker's deleted-point bitslice). pub fn flusher(&self) -> Flusher { Box::new(|| Ok(())) } @@ + /// Marks `idx` as deleted in the in-memory bitmap. + /// + /// Note: this is **not** persisted. On reopen, deletions must be + /// re-supplied via the `deleted_points` argument to [`Self::open`]. pub fn remove_point(&mut self, idx: PointOffsetType) {Also applies to: 312-318
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs` around lines 236 - 238, Add clear doc comments to MmapNumericIndex, its flusher() method, and remove_point() explaining that deletions are in-memory only and not persisted: flusher() is a no-op and remove_point() only updates the in-memory deleted BitVec; callers must re-supply the deleted BitSlice to open() (e.g. id_tracker.deleted_point_bitslice()) when reloading to restore deletions. Mention this contract succinctly on the struct and both methods so consumers do not assume deletions are persisted.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs`:
- Around line 236-238: Add clear doc comments to MmapNumericIndex, its flusher()
method, and remove_point() explaining that deletions are in-memory only and not
persisted: flusher() is a no-op and remove_point() only updates the in-memory
deleted BitVec; callers must re-supply the deleted BitSlice to open() (e.g.
id_tracker.deleted_point_bitslice()) when reloading to restore deletions.
Mention this contract succinctly on the struct and both methods so consumers do
not assume deletions are persisted.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fafb1f84-1069-4b9f-9b15-17e238d381b5
📒 Files selected for processing (2)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rslib/segment/src/index/field_index/numeric_index/tests.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/index/field_index/numeric_index/mmap_numeric_index.rs`:
- Around line 186-195: The current code bitor_assigns the entire mapped
bit-slice (deleted_payloads_bitslice) into deleted, which can be longer than the
logical point count and causes panics for non-word-aligned segments; before
calling deleted.bitor_assign(...), truncate/slice the mapped bit slice to the
logical length point_to_values.len() (use deleted_payloads_bitslice.as_ref() or
equivalent view and take only the first point_to_values.len() bits) so the two
bitsets have equal lengths when calling bitor_assign on deleted_payload_mmap /
deleted_payloads_bitslice / deleted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 56a1cc11-38fb-4e03-acdd-fdc5e9d1aa8b
📒 Files selected for processing (1)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs
Do not use a deleted mmap-ed storage, instead, reconstruct a bitmask from the index and segment-level deleted mask. It effectively makes the mmap numeric index immutable, and immutable numeric index too as it delegates the storage to mmap numeric index.
It is more compact than count data we read before to check for cleared payloads.
* use bitwise operations instead of loop * [AI] Only propagate bitslice * fmt
It must be the same length as `point_to_values` length.
d765c28 to
5324e41
Compare
5324e41 to
99f5bf1
Compare
* Immutable storage for mmap numeric index Do not use a deleted mmap-ed storage, instead, reconstruct a bitmask from the index and segment-level deleted mask. It effectively makes the mmap numeric index immutable, and immutable numeric index too as it delegates the storage to mmap numeric index. * Index reload tests * Make clippy happy * Restore deletion bitmask to reduce IO on index load It is more compact than count data we read before to check for cleared payloads. * immutable payload index storage 1 bis review (#8638) * use bitwise operations instead of loop * [AI] Only propagate bitslice * fmt * Fix deleted bitmask length It must be the same length as `point_to_values` length. * account for ram usage * Default missing external deletion bits to live, not deleted. * clear doc for flush --------- Co-authored-by: Andrey Vasnetsov <[email protected]> Co-authored-by: Arnaud Gourlay <[email protected]>
Do not use a deleted mmap-ed storage, instead, reconstruct a bitmask from the index and segment-level deleted mask. It effectively makes the mmap numeric index storage immutable, and immutable numeric index storage too as it delegates to mmap numeric index.
It would reduce IO at Qdrant serverless instances.
All Submissions:
devbranch. Did you create your branch fromdev?New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --workspace --all-featurescommand?Changes to Core Features: