You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let n_entries = end - since;
let apply_results = self.state_machine.apply(entries).await?;
Now that this is in the same method, it would make sense to somehow overlap the processing. E.g., change the interface of getting log entries to a (semi-async) iterator (which can do prefetching as it sees fit for on-disk data) and feed this iterator to apply() directly? The result could be another (semi-async) iterator, which you can then use to get rid of applying_entries.
Upgrade RaftLogReader::try_get_log_entries() -> Result<Vec<Entry>, StorageError> to return a pollable result, a Stream or an iterator of Future.
So that prefetch can be done before the caller consuming log entries.
traitRaftLogReader{// Return a Stream:asyncfntry_get_log_entries(&mutself,range) -> implStream<Item=Result<Entry,StorageError>>;// Or return an iterator of FuturetypeFu:Future<Item=Result<Entry,StorageError>>;asyncfntry_get_log_entries(&mutself,range) -> implIterator<Item=Fu>;}
The text was updated successfully, but these errors were encountered:
@schreter
Does these two forms of return type look good to you?
Usually I prefer Stream because it is more generic than a iterator of Future, because itself is poll-able, but an iterator might block a task when fetching the next Future item.
openraft/src/core/sm/worker.rs
line 166 at r1 (raw file):Now that this is in the same method, it would make sense to somehow overlap the processing. E.g., change the interface of getting log entries to a (semi-async) iterator (which can do prefetching as it sees fit for on-disk data) and feed this iterator to
apply()
directly? The result could be another (semi-async) iterator, which you can then use to get rid ofapplying_entries
.Originally posted by @schreter in #1154 (review)
Upgrade
RaftLogReader::try_get_log_entries() -> Result<Vec<Entry>, StorageError>
to return a pollable result, a Stream or an iterator of Future.So that prefetch can be done before the caller consuming log entries.
The text was updated successfully, but these errors were encountered: