Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 a 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 ``` Initial benchmarks show up to 7.5x improvements in the restore speed: ``` Instances Backup Size Concurrency Span Mb Restore time PBM-875_concurrent_download_buf branch i3en.xlarge (4vCPU,16Gb RAM) 500Gb 4 32 45min i3en.xlarge (4vCPU,16Gb RAM) 500Gb 6 32 33min i3en.xlarge (4vCPU,16Gb RAM) 500Gb 8 32 32min i3en.xlarge (4vCPU,16Gb RAM) 500Gb 4 64 42min i3en.xlarge (4vCPU,16Gb RAM) 500Gb 4 128 40min main branch (v2.0.3) i3en.xlarge (4vCPU,16Gb RAM) 500Gb - - 240 min ```
- Loading branch information
Showing
10 changed files
with
746 additions
and
236 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Oops, something went wrong.