feat(xio): make copy buffer size configurable - #11660
Merged
Merged
Conversation
Document the context-aware copy buffer option and its validation plan. Assisted-by: Codex:gpt-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds functional options to
xio.Copyand aWithBufferSizeoption. Copies use a 1 MiB buffer by default while existing callers remain source compatible. Non-positive overrides fall back to the default.This addresses severe progress-callback amplification during large model imports. The downloader reports progress after every copy chunk. In distributed mode, each report synchronously updates
gallery_operationsin PostgreSQL and publishes progress through NATS. The previous 32 KiB chunks can therefore turn one large import into hundreds of thousands of database updates and messages.A live 10-second sample during a slow import recorded 250 NATS input messages and 244 PostgreSQL row updates. At 32 KiB per callback, 25 callbacks per second corresponds to 0.78 MiB/s, matching the observed import rate. A 1 MiB buffer reduces callback frequency by about 32x.
A separate production-shaped NAS probe showed similar raw SMB write throughput for both buffer sizes: 32 KiB averaged 71.7 MiB/s and 1 MiB averaged 72.3 MiB/s. This confirms that callback amplification, rather than CIFS write coalescing, is the bottleneck.
Notes for Reviewers
go test ./pkg/xio ./pkg/downloader ./pkg/ocigo test ./pkg/xio -run "^$" -bench BenchmarkCopy -benchtime=1xSigned commits