feat(index): batch invalidation writes for improved performance#626
Draft
feat(index): batch invalidation writes for improved performance#626
Conversation
Change invalidation persistence strategy from immediate disk writes to in-memory buffering with periodic flushing. This reduces I/O overhead when processing document deletions. Key changes: MultiSpannIndex: - `invalidate()` and `invalidate_batch()` now only update in-memory state - Add `flush_invalidations()` to persist buffered invalidations to disk - Track pending invalidations in `DashMap<u128, HashSet<u128>>` MutableSegment: - Buffer invalidations in `DashMap` during `invalidate()` calls - Write all pending invalidations to disk during `build()` via `InvalidatedIdsStorage` ImmutableSegment: - Add `pending_invalidations: RwLock<HashMap<u128, HashSet<u128>>>` - Add `flush_invalidations()` method called during segment operations - `remove()` now buffers instead of immediately persisting Collection: - Call `flush_invalidations()` on finalized segments during flush io_uring improvements (uring_engine.rs, uring_file.rs): - Fix buffer pinning: use `Pin<Vec<u8>>` instead of `Pin<Box<Vec<u8>>>` - Replace `std::sync::Mutex` with `tokio::sync::Mutex` for async safety - Add explicit Send/Sync impls for UringFile - Fix Clippy warning: use `for` loop instead of `while let` This design batches disk writes for deletions, reducing I/O overhead while maintaining consistency by flushing during segment build/flush operations.
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.
Change invalidation persistence strategy from immediate disk writes to in-memory buffering with periodic flushing. This reduces I/O overhead when processing document deletions.
Key changes:
MultiSpannIndex:
invalidate()andinvalidate_batch()now only update in-memory stateflush_invalidations()to persist buffered invalidations to diskDashMap<u128, HashSet<u128>>MutableSegment:
DashMapduringinvalidate()callsbuild()viaInvalidatedIdsStorageImmutableSegment:
pending_invalidations: RwLock<HashMap<u128, HashSet<u128>>>flush_invalidations()method called during segment operationsremove()now buffers instead of immediately persistingCollection:
flush_invalidations()on finalized segments during flushio_uring improvements (uring_engine.rs, uring_file.rs):
Pin<Vec<u8>>instead ofPin<Box<Vec<u8>>>std::sync::Mutexwithtokio::sync::Mutexfor async safetyforloop instead ofwhile letThis design batches disk writes for deletions, reducing I/O overhead while maintaining consistency by flushing during segment build/flush operations.