-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(storage-manager): replication log lookup #1566
refactor(storage-manager): replication log lookup #1566
Conversation
This method now iterates over both the `SubIntervalIdx` and `SubInterval` instead of only the `SubInterval`. This change will be needed to optimise the `LogLatest::lookup` method. * plugins/zenoh-plugin-storage-manager/src/replication/classification.rs: change the signature of the method `Interval::sub_intervals` to iterate over both the sub-interval index and sub-interval. * plugins/zenoh-plugin-storage-manager/src/replication/core/aligner_query.rs: update due to the change. Signed-off-by: Julien Loudet <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic makes sense to me. I also ran the intergration tests and it looks good.
Found two nitpicks to be addressed 😅
plugins/zenoh-plugin-storage-manager/src/replication/classification.rs
Outdated
Show resolved
Hide resolved
if event.timestamp >= event_to_lookup.timestamp { | ||
EventLookup::NewerOrIdentical(event) | ||
} else { | ||
EventLookup::Older |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure it will never be useful to get the event in case of an EventLookup::Older
?
IMO semantically the event exists, we should return it and it should be up to the calling logic to use it or not (unless this has a significant impact on performance).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your point of view however as that code is only called from the Replication and that, for now, there are no cases where the metadata of an older event is needed, adding it brings no value (YAGNI).
This commit optimises the method `lookup` to only lookup for newer (and thus rename it to `lookup_newer`) Event. As it is only looking for a newer Event, this method skips the Intervals and SubIntervals that, by construction of the Replication Log, only contain Events with lower timestamps. * plugins/zenoh-plugin-storage-manager/src/replication/classification.rs: - Added new enumeration `EventLookup`. - Removed the `Interval::lookup` method as this commit made it unneeded. - Updated the `SubInterval::lookup` method to return the newly created `EventLookup` enumeration. * plugins/zenoh-plugin-storage-manager/src/replication/core/aligner_reply.rs: - Removed the code to filter out an Event with an older timestamp as the method `LogLatest::lookup_newer` already does it. - Create the `EventMetadata` before calling `LogLatest::remove_event` to avoid multiple borrows. * plugins/zenoh-plugin-storage-manager/src/replication/log.rs: renamed the method `LogLatest::lookup` to `LogLatest::lookup_newer` and modified its behaviour to only look for newer Event. * plugins/zenoh-plugin-storage-manager/src/storages_mgt/service.rs: only test if `LogLatest::lookup_newer` returned something. Signed-off-by: Julien Loudet <[email protected]>
32b93d8
to
9b5c1d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This commit optimises the method
lookup
to only lookup for newer (andthus rename it to
lookup_newer
) Event.As it is only looking for a newer Event, this method skips the Intervals
and SubIntervals that, by construction of the Replication Log, only
contain Events with lower timestamps.