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

PBM-875: concurrent download #776

Merged
merged 18 commits into from Feb 3, 2023
Merged

Conversation

dAdAbird
Copy link
Member

@dAdAbird dAdAbird commented Jan 23, 2023

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 next
downloaded 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 to
the consumer.
The max size the buffer of would be arenaSize * concurrency. Where
arenaSize is spanSize * spansInArena. It doesn't mean all of this size
would 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.Wrire
and 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:

restore:
 ...
	// NumDownloadWorkers sets the num of goroutine would be requesting chunks
	// during the download. By default, it's set to GOMAXPROCS.
	// Default: num of CPU cores
	numDownloadWorkers int
	// MaxDownloadBufferMb sets the max size of the in-memory buffer that is used
	// to download files from the storage.
	// Default: 0 - `numDownloadWorkers * downloadChunkMb * 16`
	maxDownloadBufferMb int
	// Default: 32 (32Mb)
	downloadChunkMb int 

@JNKPercona
Copy link
Collaborator

Test name Logical Physical
New cluster psmdb 4.2 failed -
New cluster psmdb 4.4 failed -
New cluster psmdb 5.0 failed -
Non-sharded psmdb 4.2 failed failed
Sharded psmdb 4.2 failed failed
Sharded psmdb 4.4 failed failed
Non-sharded psmdb 4.4 failed failed
Sharded psmdb 5.0 failed failed
Non-sharded psmdb 5.0 failed failed
Single-node psmdb 4.2 failed failed
Single-node psmdb 4.4 failed failed
Single-node psmdb 5.0 failed failed

@JNKPercona
Copy link
Collaborator

Test name Logical Physical
New cluster psmdb 4.2 passed -
New cluster psmdb 4.4 passed -
New cluster psmdb 5.0 passed -
Sharded psmdb 4.2 passed failed
Non-sharded psmdb 4.4 passed failed
Non-sharded psmdb 4.2 failed failed
Sharded psmdb 5.0 failed failed
Sharded psmdb 4.4 failed failed
Non-sharded psmdb 5.0 passed passed
Single-node psmdb 4.2 passed failed
Single-node psmdb 5.0 passed passed
Single-node psmdb 4.4 passed failed

@JNKPercona
Copy link
Collaborator

Test name Logical Physical
Sharded psmdb 4.2 failed failed
Sharded psmdb 4.4 failed failed
Sharded psmdb 5.0 failed passed

@JNKPercona
Copy link
Collaborator

Test name Logical Physical
New cluster psmdb 4.2 failed -
New cluster psmdb 4.4 passed -
New cluster psmdb 5.0 passed -
Non-sharded psmdb 4.2 failed failed
Non-sharded psmdb 4.4 passed passed
Non-sharded psmdb 5.0 passed passed
Single-node psmdb 4.2 failed failed
Single-node psmdb 4.4 failed passed
Single-node psmdb 5.0 passed passed
Sharded psmdb 4.4 failed passed
Sharded psmdb 4.2 failed failed
Sharded psmdb 5.0 failed passed

@dAdAbird dAdAbird marked this pull request as ready for review January 24, 2023 14:54
@dAdAbird dAdAbird requested a review from defbin as a code owner January 24, 2023 14:54
@JNKPercona
Copy link
Collaborator

Test name Logical Physical
New cluster psmdb 4.2 failed -
New cluster psmdb 4.4 passed -
New cluster psmdb 5.0 passed -
Non-sharded psmdb 4.2 failed failed
Non-sharded psmdb 4.4 passed passed
Non-sharded psmdb 5.0 passed passed
Sharded psmdb 4.2 failed failed
Sharded psmdb 4.4 failed passed
Sharded psmdb 5.0 failed failed
Single-node psmdb 4.2 failed failed
Single-node psmdb 4.4 failed passed
Single-node psmdb 5.0 failed passed

defbin
defbin previously approved these changes Jan 27, 2023
@JNKPercona
Copy link
Collaborator

Test name Logical Physical
New cluster psmdb 4.4 failed -
New cluster psmdb 5.0 failed -
Sharded psmdb 4.2 failed failed
New cluster psmdb 4.2 failed -
Non-sharded psmdb 4.2 failed failed
Sharded psmdb 4.4 failed failed
Sharded psmdb 5.0 failed failed
New cluster psmdb 6.0 failed -
Non-sharded psmdb 4.4 failed failed
Non-sharded psmdb 5.0 failed failed
Non-sharded psmdb 6.0 failed failed
Sharded psmdb 6.0 failed failed
Single-node psmdb 4.2 failed failed
Single-node psmdb 4.4 failed failed
Single-node psmdb 5.0 failed failed
Single-node psmdb 6.0 failed failed

@JNKPercona
Copy link
Collaborator

Test name Logical Physical
Single-node psmdb 4.2 failed passed
New cluster psmdb 6.0 failed -
Sharded psmdb 4.4 failed passed
Single-node psmdb 4.4 failed passed
New cluster psmdb 5.0 passed -
Non-sharded psmdb 4.2 passed passed
Non-sharded psmdb 6.0 failed passed
Non-sharded psmdb 4.4 failed passed
Sharded psmdb 5.0 failed passed
Non-sharded psmdb 5.0 failed passed
Sharded psmdb 6.0 failed failed
Sharded psmdb 4.2 failed failed
Single-node psmdb 5.0 failed passed
New cluster psmdb 4.4 passed -
Single-node psmdb 6.0 failed passed
New cluster psmdb 4.2 passed -

@JNKPercona
Copy link
Collaborator

Test name Logical Physical
New cluster psmdb 4.4 passed -
New cluster psmdb 6.0 failed -
New cluster psmdb 5.0 passed -
New cluster psmdb 4.2 passed -
Sharded psmdb 4.2 failed passed
Sharded psmdb 4.4 failed passed
Sharded psmdb 5.0 failed passed
Sharded psmdb 6.0 failed failed
Non-sharded psmdb 4.2 failed passed
Non-sharded psmdb 4.4 passed passed
Single-node psmdb 4.2 passed passed
Non-sharded psmdb 6.0 passed passed
Non-sharded psmdb 5.0 passed passed
Single-node psmdb 5.0 failed passed
Single-node psmdb 6.0 passed passed
Single-node psmdb 4.4 passed failed

@dAdAbird dAdAbird merged commit 85b566e into main Feb 3, 2023
@dAdAbird dAdAbird deleted the PBM-875_concurrent_download_buf branch February 3, 2023 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants