Skip to content
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

Support to fetch entries asynchronously #447

Open
hicqu opened this issue Jun 28, 2021 · 4 comments
Open

Support to fetch entries asynchronously #447

hicqu opened this issue Jun 28, 2021 · 4 comments

Comments

@hicqu
Copy link
Contributor

hicqu commented Jun 28, 2021

Is your feature request related to a problem? Please describe.

In the current API new appended entries and committed entries are fetched into Ready synchronously. However In many cases we want to fetch them asynchronously. For example:

  • There are lots of entries need to be fetched and it is not expected to block the current thread;
  • The memory usage is almost reach the limit, it it not expected to fetch lots of entries into memory.

Describe the solution you'd like

Adjust Ready to

fn Ready::entries(&self) -> Either<&[Entries], Range<u64>>;
fn Ready::committed_entries(&self) -> Either<&[Entries], Range<u64>>;

And add 2 new fields into Config:

pub struct Config {
    fetch_entries_asynchronously: bool,
    fetch_committed_entries_asynchronously: bool,
}
@hicqu
Copy link
Contributor Author

hicqu commented Jun 28, 2021

@BusyJay @gengliqi @Little-Wallace PTAL.

@gengliqi
Copy link
Member

I think we should also consider the entries in AppendEntries msg. They can be fetched asynchronously too.

@BusyJay
Copy link
Member

BusyJay commented Jun 28, 2021

Log term should also be checked.

@hicqu
Copy link
Contributor Author

hicqu commented Jun 28, 2021

Log term should also be checked.

How about maintain terms with a Vec<(term, index) in memory for uncompacted entries? And only the first entry in a term needs to be recorded, so it won't be expensive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants