Skip to content

feat(volumes): stream put parts and make upload concurrency tunable - #224

Merged
emmmile merged 7 commits into
mainfrom
feat/volumes-put-concurrency
Nov 27, 2026
Merged

emmmile merged 7 commits into
mainfrom
feat/volumes-put-concurrency

Conversation

@emmmile

@emmmile emmmile commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

runware serverless volumes put gains --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 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, 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 put aborts without publishing anything. 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.

The help and the missing-organization error now say to add a top-level organization: <id> line to ~/.runware/config.yaml (which config set cannot set) or to set RUNWARE_ORGANIZATION.

Written with Claude Code (Claude Opus 5.5).

`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.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 15:29
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include coderabbit-review in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 562afaea-be62-4c8a-a8e1-5519c12e748b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 --concurrency from 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
danmrichards previously approved these changes Nov 26, 2026

@danmrichards danmrichards left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Dan Richards's agent (Claude), not Dan Richards.

Added 2 suggestions and a todo. LGTM ✅

Comment thread internal/volumes/put/run.go Resolved
Comment thread internal/volumes/put/parts.go Resolved
Comment thread internal/volumes/put/put_test.go Resolved
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
danmrichards previously approved these changes Nov 26, 2026

@danmrichards danmrichards left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Dan Richards's agent (Claude), not Dan Richards.

Added a suggestion and a todo. LGTM ✅

Comment thread internal/volumes/put/parts.go Resolved
Comment thread internal/volumes/put/part_retry_test.go Resolved
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
danmrichards previously approved these changes Nov 27, 2026

@danmrichards danmrichards left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Dan Richards's agent (Claude), not Dan Richards.

Added a suggestion and a todo, and a reply on the slow-link thread. LGTM ✅

Comment thread internal/volumes/put/parts.go Resolved
Comment thread internal/volumes/put/parts.go Resolved
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
danmrichards previously approved these changes Nov 27, 2026

@danmrichards danmrichards left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Dan Richards's agent (Claude), not Dan Richards.

Added a suggestion and a todo. LGTM ✅

Comment thread internal/volumes/put/parts.go Resolved
Comment thread internal/volumes/put/part_retry_test.go Resolved
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 danmrichards left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Dan Richards's agent (Claude), not Dan Richards.

Added a todo. LGTM ✅

Comment thread internal/volumes/put/part_retry_test.go Resolved
@emmmile
emmmile merged commit 0f7fafc into main Nov 27, 2026
6 of 7 checks passed
@emmmile
emmmile deleted the feat/volumes-put-concurrency branch November 27, 2026 10:39
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.

3 participants