Repository navigation
feat(core): let finished connections take over slower ones' remaining bytes - #581
Conversation
… bytes A connection that finishes its segment now splits the tail off the connection expected to finish last, where both finish together from their measured rates (in half until known), instead of closing. Only ranges of at least 1 MiB are handed over and never without range support. Sources write through SegmentLane.admit/commit, and a lane whose tail was taken ends its transfer at its new end. HTTP and FTP use it.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83ba80cf7c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…request quotas Closing the data and control sockets ran in a cancellable withContext, so a pause or a takeover that cancelled an idle FTP transfer could leave them open; they now close under NonCancellable. Taking over a range sends one more request, so downloads whose server reports RateLimit-Remaining no longer take ranges over.
Test Results 2 052 files + 4 2 080 suites +4 32m 21s ⏱️ +8s Results for commit ae814c6. ± Comparison against base commit 1ad0e33. This pull request removes 4 and adds 66 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
…k-stealing-segments # Conflicts: # AGENTS.md # README.md
Implements the README roadmap item Faster segmented downloads: connections that finish early take over the rest of the slower ones, so a download no longer waits on its slowest connection.
How it works
SegmentLaneon one connection. When a lane finishes, its connection asksSegmentLedger.stealfor the tail of the lane expected to finish last and downloads it with a request of its own, instead of closing.DEFAULT_MIN_SPLIT_BYTES) are handed over, so small files stay on their connections; never without range support.SegmentLane.admitallows and report it withcommit. A lane whose tail was taken ends its transfer once it reaches its new end (aCancellationExceptionthe helper counts as done), which closes the response.API change
SegmentedDownloadHelper.downloadAll's transfer lambda now takes aSegmentLaneinstead of(Segment, onProgress) -> Segment;HttpDownloadSourceandFtpDownloadSourceare updated. Pre-1.0, so allowed.Not in this PR
A failed range still fails the whole batch (retried from saved segments); retrying a range alone is next (AGENTS.md roadmap item 6, now "Lane scheduler").
Tests
SegmentLedgerTest: half splits, admitted bytes never moved, minimum tail, rate-based split point, stalled victim, refusing splits that would not finish sooner, cut lanes ending their transfer.SegmentedDownloadHelperTest: a fast connection takes over a slow one's bytes on virtual time, every byte written once; no splits without range support.HttpDownloadSourceTest: a 4 MiB download with a slow second connection is taken over and written byte-for-byte correctly.:library:core:jvmTest,:library:ftp:jvmTestand:library:core:compileTestKotlinIosSimulatorArm64pass locally.