Repository navigation
feat(engine): open connections one at a time - #11
Conversation
troke12
left a comment
There was a problem hiding this comment.
WaitGroup/lifecycle looks correct. Changes I'd like:
- One slow connection freezes the ramp: connection k+1 only opens after k gets its first byte. If k never does (cold edge, per-IP queueing, slow headers), the remaining connections never open, where
mainwould have opened all N. Please add a timeout, or gate on "any newly opened connection received bytes". - After any worker error sets
StatusError, ramping stops for good even if the run can still complete. - Should respect #10's single-connection mode (
alone). - Tests use a 150 ms
Sleepto prove something didn't happen; please synchronise with channels/counters. Thearrivalschannel (cap 4) blocks the handler on any extra request — and #8's0-0probe will be counted byexplicitRange.
Note for the whole set (#1–#11): thanks a lot for these! They are all branched from 5350f79 independently, so every pair conflicts on CHANGELOG.md and most on download.go. main has also moved (e830f5d adds a stream downloader that touches download.go). Could you rebase onto current main and stack them in this order: #1 → #2 → #10 → #8 → #5/#6/#7/#11? #2, #3 and #10 each add their own pass loop / transferCancel in Start; one shared design would be much easier to merge.
Brings the eleven engine changes (troke12/odm troke12#1-troke12#11) onto upstream v0.3.0-rc1. Conflicts in CHANGELOG.md and internal/engine/download.go keep both sides: the stream fields and the d.Stream branch from upstream run before the engine's pass loop, and State saves both the validators and the stream job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The next connection starts after every connection already open has stored file bytes, up to the configured limit.
Review changes on top of the previous commit, which ports troke12#11 onto the pass loop on main: - The next connection opens once file bytes arrive on any connection after the last one opened, not once every opened connection has had bytes. A connection that never got its first byte froze the ramp for good, where main opened all N; now the others keep it going (TestRampPassesAStalledConnection). Without a timer, a server that refuses every transfer is still not asked on more connections. - ramp runs as its own goroutine holding a count on the pass's WaitGroup, and ends when every connection is open, the pass ends, or nothing is left to hand out (hasWork). A worker error no longer stops it: the run may still complete. - One-connection mode (troke12#10) and !RangeOK open a single connection. - Tests use no sleeps to show something did not happen: only file bytes open a connection, so while bytes are held back none can. They count opened connections (rampOpened), not requests, and tell the probe by bytes=0-0 (isProbe). ✨ Generated with Claude Code (claude.ai/claude-code) 2.1.303 (claude-opus-5-5)
ffd4737 to
4e82d00
Compare
|
Rebased onto current |
Summary
A segmented download used to open all N connections at once. Now it opens them one at a time: the first one immediately, and each next one once file bytes arrive on any connection after the last one opened, up to the configured limit.
503, a queue, an edge still warming up) sends no bytes, so it is not asked on more connections.How
rampruns as its own goroutine in the pass loop and holds a count on the pass'sWaitGroupwhile it may add workers, soWaitcannot return early. Writes signal it under the same lock that updates chunk progress (rampArmed/rampReady). It ends when every connection is open, the pass ends (pause, changed file, ignored range), or nothing is left to hand out (hasWork).Commits
fac05d8(Ryan Bagas): the original change, ported onto the pass loop onmain. Its test fails at this commit because thebytes=0-0probe counts as a transfer.4e82d00: review changes. Any-connection bytes gate,rampgoroutine, no stop on worker error, tests rewritten without sleeps.Test plan
go test ./...,go test -race ./internal/engine, ramp tests ×5 with-raceTestConnectionsRampAfterFileBytes: one connection until bytes arrive, then all 4. It counts opened connections, not requests.TestRampPassesAStalledConnection: connection 2 hangs before headers and connection 3 still opens. Fails when the ramp only re-arms for the first connection.TestRefusedResponseDoesNotOpenMoreConnections: a server refusing every transfer gets only one connection while it retries.TestRampRespectsOneConnectionMode: fails if the pass ignoresalone.✨ Generated with Claude Code (claude.ai/claude-code) 2.1.303 (claude-opus-5-5)