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

feat(download): optimistic downloader #881

Closed
wants to merge 2 commits into from

Conversation

rkrasiuk
Copy link
Member

Closes #764
Implementation of an optimistic downloader service

@rkrasiuk rkrasiuk added C-enhancement New feature or request A-networking Related to networking in general labels Jan 13, 2023
@rkrasiuk rkrasiuk marked this pull request as draft January 13, 2023 16:53
Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see a draft up 😄 Got some questions

#[derive(Clone, Debug)]
pub(crate) enum DownloadOrigin<T> {
/// The remote download origin.
Remote(MessageSender<T>),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this variant for?

Copy link
Member Author

@rkrasiuk rkrasiuk Jan 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two types of downloads: requested externally and self initiated. this variant contains the sender for the external response channel

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requested externally and self initiated. this variant contains the sender for the external response channel

do we plan/need to call this from multiple places? if so, why?
I thought this downloader is just for the bodies stage

pub enum DownloaderError {
/// The downloader is at capacity and cannot process new requests.
#[error("Downloader is at maximum capacity.")]
Full,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note here that this should not be an error that reaches the stages as it doesn't matter if the downloader is full, the stages only empty the buffer. Not sure when this error is thrown?

}
}

impl<B, C> BodiesDownload<B, C> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think technically these futures are up to the client that the downloader has a handle to, right? We don't need retry logic anymore really since we should retry forever, and we should not backoff because we can't know where the request is routed to

pub(crate) struct DownloadBuffer {
// TODO: merge two buffers?
/// Internal header buffer
headers: LruCache<H256, SealedHeader>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of LruCache vs a Vec with a fixed capacity?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a LruCache vs a HashMap with a fixed capacity would be a better comparison. it's LRU for now, but I'm still thinking about whether it introduces additional complexity. the benefit is that the headers buffer is used to lookup downloaded headers for both headers and bodies requests

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these actually two separate things?

because this now adds a new downloader type while also refactoring the existing types?

I'm also not sure what "optimistic" here means?

client: Arc<N>,
consensus: Arc<C>,
config: DownloaderConfig,
request_rx: UnboundedReceiverStream<DownloaderMessage>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this take a receiver?

how will this be used inside the stage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to a NetworkHandle, i'll create a DownloaderHandle which would be able to forward requests to the downloader

@rkrasiuk rkrasiuk closed this Jan 16, 2023
@rkrasiuk rkrasiuk deleted the rkrasiuk/feat-optimistic-donwloader branch February 13, 2023 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Related to networking in general C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a downloader component separate from the stages
3 participants