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
PBM-875: concurrent download #776
Merged
Merged
Conversation
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
|
|
|
|
|
defbin
previously approved these changes
Jan 27, 2023
|
defbin
approved these changes
Feb 2, 2023
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Each object can be downloaded concurrently in chunks. If a download of a
chunk has failed it will be retried a certain amount of time before
returning with an error.
It starts with the number of workers equal to the concurrency setting. Each
worker takes a task with a needed object range (chunk) and downloads it into
a part (span) of its memory buffer (arena). Returns an io.ReaderCloser
object with the content of the span. And gets a next free span to download
the next chunk.
The consumer closing io.ReaderCloser marks the respective span as free reuse.
An arenas pool is created with the
Download
object and reused for every nextdownloaded object.
Although the object's chunks can be downloaded concurrently, they should be
streamed to the consumer sequentially (objects usually are compressed, hence
the consumer can't be an oi.Seeker). Therefore if a downloaded span's range
is out of order (preceding chunks aren't downloaded yet) it is added to the
heap structure (
chunksQueue
) and waits for its queue to be passed tothe consumer.
The max size the buffer of would be
arenaSize * concurrency
. WherearenaSize
isspanSize * spansInArena
. It doesn't mean all of this sizewould be allocated as some of the span slots may remain unused.
Download arena (bytes slice) is split into spans (represented by
dpsan
)whose size should be equal to download chunks.
dspan
implements io.Wrireand io.ReaderCloser interface. Close() marks the span as free to use
(download another chunk).
Free/busy spans list is managed via lock-free bitmap index.
New config options: