Skip to content

feat(client): stream ParallelGet in-order to an io.Writer#360

Draft
worstell wants to merge 1 commit into
mainfrom
worstell/parallel-get-stream
Draft

feat(client): stream ParallelGet in-order to an io.Writer#360
worstell wants to merge 1 commit into
mainfrom
worstell/parallel-get-stream

Conversation

@worstell

@worstell worstell commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

ParallelGet previously wrote chunks to an io.WriterAt, which requires a seekable destination (e.g. a temp file) and so prevents a consumer from overlapping the download with processing. It now fetches chunks in parallel but emits in-order bytes to a plain io.Writer via a bounded reorder buffer, letting a streaming consumer (e.g. a decompress/extract pipeline) run concurrently with the download.

A concurrency-sized window caps fetched-but-unwritten chunks, bounding peak memory to O(concurrency * chunkSize) regardless of object size or consumer speed. Revision safety (ETag pinning via If-Range), empty-object handling, range-ignore degrade, and the concurrency == 1 shortcut are unchanged.

This is a single API: the io.WriterAt variant is removed (it had no consumer that benefited from scatter-writes, and the only use — download-to-temp-file then extract — is slower than streaming because it gives up download/extract overlap).

ParallelGet previously wrote chunks to an io.WriterAt, which requires a seekable
destination (e.g. a temp file) and so prevents a consumer from overlapping the
download with processing. It now fetches chunks in parallel but emits in-order
bytes to a plain io.Writer via a bounded reorder buffer, letting a streaming
consumer (e.g. a decompress/extract pipeline) run concurrently with the
download.

A concurrency-sized window caps fetched-but-unwritten chunks, bounding peak
memory to O(concurrency * chunkSize) regardless of object size or consumer
speed. Revision safety (ETag pinning via If-Range), empty-object handling,
range-ignore degrade, and the concurrency==1 shortcut are unchanged.

Amp-Thread-ID: https://ampcode.com/threads/T-019ef6a9-a407-7389-bc43-001405e3ae9e
Co-authored-by: Amp <amp@ampcode.com>
@worstell worstell force-pushed the worstell/parallel-get-stream branch from 4d97fb3 to 83e3e16 Compare June 26, 2026 00:30
@worstell worstell changed the title feat(client): add ParallelGetStream for in-order streaming parallel downloads feat(client): stream ParallelGet in-order to an io.Writer Jun 26, 2026
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

Successfully merging this pull request may close these issues.

1 participant