forked from eclipse-zenoh/zenoh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(storage-manager): optimise insertion during Replication
Before this commit, the Replication Log was searched twice when aligning an Event: once while calling `lookup` and a second time when calling `insert_event`. To reduce the number of searches to a single one, the method `insert_event_unchecked` was introduced. This function assumes that the Replication Log contains no Event with the same key expression as the Event it will insert. Leveraging this, the calls to `LogLatest::lookup` followed by `LogLatest::insert_event` were replaced with calls to `LogLatest::remove_older` followed by `LogLatest::insert_event_unchecked`. Indeed, if the call to `LogLatest::remove_older` yields either `NotFound` or `RemovedOlder` then the Replication Log does not contain any event with the key expression, and `LogLatest::insert_event_unchecked` can be confidently called. Another consequence of the introduction of the new method `insert_event_unchecked` is that the variant `EventInsertion::NotInsertedAsOutOfBound` was no longer used and was thus removed. * plugins/zenoh-plugin-storage-manager/src/replication/core/aligner_reply.rs: Replaced the calls to `lookup` followed by `insert_event` to calls to `remove_older` followed by `insert_event_unchecked` in the methods `process_event_metadata` and `process_event_retrieval`. * plugins/zenoh-plugin-storage-manager/src/replication/log.rs: - Removed the no longer used `EventInsertion::NotInsertedAsOutOfBound` variant. - Added a comment to clearly indicate that the method `insert_event` will remove older Event. - Introduced the new method `insert_event_unchecked` that inserts an Event in the Replication Log without checking if it is the only Event (i.e. it assumes it is the case). Signed-off-by: Julien Loudet <[email protected]>
- Loading branch information
Showing
2 changed files
with
61 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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