Skip to content

perf: parallel segmented snapshot downloads#23028

Open
decofe wants to merge 7 commits intomainfrom
perf/parallel-segmented-downloads
Open

perf: parallel segmented snapshot downloads#23028
decofe wants to merge 7 commits intomainfrom
perf/parallel-segmented-downloads

Conversation

@decofe
Copy link
Copy Markdown
Member

@decofe decofe commented Mar 13, 2026

Closes #22944 (ports the idea to main)

Splits individual file downloads into configurable parallel segments using HTTP Range requests, matching aria2c-style parallelism. Snapshot downloads that took ~3 hours with a single connection can now complete in ~10 minutes with 16 parallel segments.

Changes

  • Added --download-segments flag (default 16, configurable per Dan's review on perf: parallel segmented snapshot downloads #22944)
  • parallel_segmented_download probes for Range support with a single-byte GET, then spawns N threads via std::thread::scope (used instead of rayon per Dan's feedback about preferring tokio/async-friendly threading; std::thread::scope works well here since the code already runs inside spawn_blocking)
  • Each segment uses FileExt::write_all_at for thread-safe positioned writes (no shared seek cursor)
  • Segment reads are capped via .take(expected_len) to prevent cross-segment overwrites
  • Validates 206 responses per segment; falls back to sequential resumable_download when server doesn't support Range requests
  • Minimum 1 MB per segment to avoid excessive overhead on small files

Testing

Existing tests pass. The parallel download path is exercised when --resumable is used (or via the modular archive pipeline) against any Range-capable server.

Co-Authored-By: Dan Cline 6798349+Rjected@users.noreply.github.com

Prompted by: Dan

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 13, 2026

⚠️ Changelog not found.

A changelog entry is required before merging. We've generated a suggested changelog based on your changes:

Preview
---
reth-cli-commands: minor
---

Added parallel segmented snapshot downloads using HTTP Range requests. A new `--download-segments` CLI flag (default: 16) controls the number of parallel segments per file, falling back to sequential download when the server does not support Range requests.

Add changelog to commit this to your branch.

@Rjected Rjected force-pushed the perf/parallel-segmented-downloads branch from 5aa70a7 to 294f8fe Compare March 13, 2026 20:59
@Rjected Rjected force-pushed the perf/parallel-segmented-downloads branch from 294f8fe to fa9b929 Compare April 8, 2026 18:20
Split individual file downloads into configurable parallel segments
using HTTP Range requests, matching aria2c-style parallelism.

Adds --download-segments flag (default 16) to control the number of
concurrent connections per file. Falls back to sequential download
when the server does not support Range requests.

Uses std::thread::scope with positioned writes (write_all_at) for
thread-safe concurrent file I/O. Each segment validates the server
returns 206 and caps reads to the expected length to prevent
cross-segment overwrites.

Co-Authored-By: Dan Cline <6798349+Rjected@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019ce82d-96b8-72d6-8cb8-f596f3f7260b
@Rjected Rjected force-pushed the perf/parallel-segmented-downloads branch from fa9b929 to b7e0b65 Compare April 8, 2026 18:27
@Rjected Rjected requested a review from gakonst as a code owner April 8, 2026 18:27
@Rjected Rjected force-pushed the perf/parallel-segmented-downloads branch 6 times, most recently from 785b1ec to e6d61b8 Compare April 10, 2026 02:22
@Rjected Rjected force-pushed the perf/parallel-segmented-downloads branch from e6d61b8 to 17030b2 Compare April 10, 2026 02:46
@Rjected Rjected force-pushed the perf/parallel-segmented-downloads branch 4 times, most recently from cd7c67b to 42e502d Compare April 10, 2026 19:27
@Rjected Rjected force-pushed the perf/parallel-segmented-downloads branch from 42e502d to c0e34e6 Compare April 10, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants