Repository navigation
feat(volumes): stream put parts and make upload concurrency tunable - #224
Conversation
`volumes put` sends --concurrency parts at once (1 to 64, default 32; it was fixed at 4). Each part streams from the file through the new volumeformat.PartSealer.StreamReader, so a part in flight holds about 1 MiB instead of its whole plaintext of about 64 MiB. StreamReader's output is byte for byte what Seal and Reader return; the wire format is unchanged. The hashing pre-pass records each part's SHA-256 with the file's, from the same read, and the hash cache keeps both (form 3, so older entries are a miss). The sender hashes each part as it streams and seals the part's last segment only once the bytes match the recorded digest, so a part that changed after hashing is never acknowledged and put aborts. Before a file's last part, put also checks that the file's size and times have not moved. A resumed upload rehashes its files instead of trusting the cache, since it does not read its acknowledged parts again, and aborts when a part's digest differs from the one journalled before. An error for a changed part names the part once, cause first. The help and the missing organization error say to add a top-level `organization: <id>` line to ~/.runware/config.yaml, which config set cannot set, or to set RUNWARE_ORGANIZATION.
|
Important Review skippedAuto reviews are disabled on this repository. To trigger a review, include
|
There was a problem hiding this comment.
🔵 Needs a closer look
Changes to encrypted-part integrity and saved-acknowledgement trust require independent review of final-segment gating and resume compatibility, plus integration and race validation unavailable in this environment.
No open issues 🎉
What changed in this PR
This PR reduces memory use in Volume uploads by streaming encrypted parts, enabling higher, configurable concurrency without changing the wire format.
Changes:
- Adds
--concurrencyfrom 1–64, defaulting to 32, with about 1 MiB of buffered data per active part. - Computes and caches per-part digests, verifies streamed content, and rehashes files when resuming uploads.
- Expands integrity, retry, memory, and concurrency tests, and clarifies organization configuration help.
| File | Description |
|---|---|
pkg/volumeformat/stream_test.go |
Tests streaming equivalence, failures, memory use, and performance. |
pkg/volumeformat/part.go |
Adds segment-based streaming encryption and source validation. |
internal/volumes/put/walk.go |
Adds per-part digests to source metadata. |
internal/volumes/put/transport.go |
Sizes idle connections for maximum concurrency. |
internal/volumes/put/transport_test.go |
Updates connection tests for the new limit. |
internal/volumes/put/sealer.go |
Changes the sealer interface to accept streams. |
internal/volumes/put/run.go |
Raises concurrency limits and improves organization guidance. |
internal/volumes/put/resume.go |
Rehashes resumed files and checks journalled part digests. |
internal/volumes/put/resume_test.go |
Tests resumed integrity checks and fresh-salt retries. |
internal/volumes/put/put_test.go |
Updates truncation tests and organization-error expectations. |
internal/volumes/put/parts.go |
Streams upload attempts and checks each part’s digest. |
internal/volumes/put/part_stream_test.go |
Tests mid-stream changes and bounded memory use. |
internal/volumes/put/part_retry_test.go |
Adapts retry fixtures to file-backed streaming. |
internal/volumes/put/part_digest_test.go |
Tests part hashing, cache behavior, and mutation detection. |
internal/volumes/put/help.go |
Documents concurrency, memory use, and organization setup. |
internal/volumes/put/hashcache.go |
Stores part digests in cache format 3 and hashes them in one pass. |
internal/volumes/put/hashcache_test.go |
Tests updated cache behavior and resume bypass. |
internal/volumes/put/dedup_test.go |
Adapts declaration fixtures to the runner’s hashing method. |
internal/volumes/put/behavior_test.go |
Updates concurrency-bound expectations. |
internal/volumes/put/api.go |
Adds source-change errors with specific causes. |
internal/cmd/serverless/volumes.go |
Registers, validates, and forwards --concurrency. |
internal/cmd/serverless/volumes_test.go |
Tests flag defaults, validation, propagation, and help. |
Review effort: Balanced
danmrichards
left a comment
There was a problem hiding this comment.
From Dan Richards's agent (Claude), not Dan Richards.
Added 2 suggestions and a todo. LGTM ✅
A part's retry window ran from its first failed attempt. With many parts sharing a slow link, one attempt can take longer than the window, so two connection drops on one part suspended the upload. The window now starts again after every failed attempt that sent part of its body, so a part keeps retrying while its attempts move data. Attempts that send nothing still stop when the window passes, and attempts that fail at once still stop at the attempt limit. Add a test that a read error while a part streams stops put at once rather than being retried as a network failure, and hold the first part in the truncation test until the size check fails, so the test does not depend on which goroutine finds the short file first.
danmrichards
left a comment
There was a problem hiding this comment.
From Dan Richards's agent (Claude), not Dan Richards.
Added a suggestion and a todo. LGTM ✅
The transport counts the part bytes the HTTP client reads, and on a stalled link the client still fills its write buffer and the kernel's send buffer before it blocks. Each stalled attempt then looked like progress and restarted the retry window, so only the attempt limit stopped the part, after about 40 minutes. The window now starts again only after a failed attempt that sent more than 16 MiB, four times the default send buffer ceiling on Linux and macOS. Slow attempts that move a part's data keep their retries. Add a test where the first attempt sends the part and later attempts stall after sending nothing or a buffer's worth, and size the existing window tests' part above the new threshold.
The window tests sent parts above the 16 MiB progress threshold, up to 18 attempts of 17 MiB each under the race detector, which pushed the package past the CI test timeout. The threshold is now a variable the tests lower to 4 KiB, so their parts are 8 KiB; the production value stays 16 MiB.
danmrichards
left a comment
There was a problem hiding this comment.
From Dan Richards's agent (Claude), not Dan Richards.
Added a suggestion and a todo, and a reply on the slow-link thread. LGTM ✅
Every retry window test lowered the 16 MiB progress threshold to 4 KiB, so the package passed with the threshold at zero, which lets a stalled link retry a part until the attempt limit. The stall test now also runs at the production threshold with an attempt that stalls after 16 MiB, and a new test drops attempts after 17 MiB of an 18 MiB part, which must restart the window because the part's data moved. The threshold is a runner field, zero meaning the production value, instead of a package variable the tests write, so a parallel test cannot race on it.
A failed attempt restarted the part's retry window only after it sent more than 16 MiB. With 32 parts sharing a 10 Mbit/s uplink, one part needs about 7 minutes to send that much, so two drops 6 minutes apart stopped the part while its data moved, and a part of 16 MiB or less never restarted the window. An attempt now also counts as progress when it kept reading the part's body for a minute or more, from its first read to its last. A stalled link fills the send buffers in one short burst and then stops reading, so it still stops at the window. Every retryable failure still counts towards the attempt limit, which stops an endpoint that reads the body and then fails.
danmrichards
left a comment
There was a problem hiding this comment.
From Dan Richards's agent (Claude), not Dan Richards.
Added a suggestion and a todo. LGTM ✅
An attempt proved progress when its first and last reads of the part's body were a minute or more apart. One burst into the send buffers and one late read, as a retransmit on a lossy link can cause, passed that test, so a stalled part restarted its retry window on every attempt and stopped only at the attempt limit, after about an hour. Reading time is now the sum of the gaps between consecutive reads, counting only gaps of at most 10 seconds. A link that moves data reads the body every second or so and still adds up a minute; a burst followed by silence adds up almost nothing, whatever comes after it. The slow-read tests now pin the one-minute boundary, the longest counted gap, the burst-silence-late-read attempt, and the attempt limit for attempts that each prove progress by their reading time.
danmrichards
left a comment
There was a problem hiding this comment.
From Dan Richards's agent (Claude), not Dan Richards.
Added a todo. LGTM ✅
runware serverless volumes putgains--concurrency(1 to 64, default 32; it was fixed at 4). Raising the default is cheap because each part now streams from the file through the newvolumeformat.PartSealer.StreamReader, so a part in flight holds about 1 MiB instead of its whole plaintext of about 64 MiB. StreamReader's output is byte for byte whatSealandReaderreturn, so the wire format is unchanged.Integrity: the hashing pass now records each part's SHA-256 alongside the file's, from the same read, and the hash cache keeps both (form 3, so older entries are a miss). The sender hashes each part as it streams and seals the part's last segment only once the bytes match the recorded digest, so a part that changed after hashing is never acknowledged and
putaborts without publishing anything. Before a file's last part,putalso checks that the file's size and times have not moved.A resumed upload rehashes its files instead of trusting the cache, since it does not read its acknowledged parts again, and aborts when a part's digest differs from the one journalled before.
The help and the missing-organization error now say to add a top-level
organization: <id>line to~/.runware/config.yaml(whichconfig setcannot set) or to setRUNWARE_ORGANIZATION.Written with Claude Code (Claude Opus 5.5).