Skip to content

impl(storage): configurable buffered upload types #2710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

coryan
Copy link
Collaborator

@coryan coryan commented Jul 17, 2025

Switch the upload type based on the size of the payload. Small uploads
perform better when using single-shot uploads. Large uploads require
resumable uploads to keep the buffer size under control, and the extra
latency is not that bad in relative terms.

Fixes #2709, fixes #2056

Switch the upload type based on the size of the payload. Small uploads
perform better when using single-shot uploads. Large uploads require
resumable uploads to keep the buffer size under control, and the extra
latency is not that bad in relative terms.
@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Jul 17, 2025
Copy link

codecov bot commented Jul 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.71%. Comparing base (9202ad7) to head (e6aeeef).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2710      +/-   ##
==========================================
+ Coverage   95.59%   95.71%   +0.11%     
==========================================
  Files          93       93              
  Lines        4018     4034      +16     
==========================================
+ Hits         3841     3861      +20     
+ Misses        177      173       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coryan coryan marked this pull request as ready for review July 17, 2025 16:31
@coryan coryan requested a review from a team as a code owner July 17, 2025 16:31
Copy link
Member

@dbolduc dbolduc left a comment

Choose a reason for hiding this comment

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

Move IterSource back into mod tests?

Comment on lines 36 to 37
// TODO(#2043) - make the threshold to use resumable uploads and the
// target size for each chunk configurable.
Copy link
Member

Choose a reason for hiding this comment

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

nit: stale comment

// TODO(#2043) - make the threshold to use resumable uploads and the
// target size for each chunk configurable.
if self.payload.lock().await.size_hint().0 > RESUMABLE_UPLOAD_QUANTUM as u64 {
let hint = self.payload.lock().await.size_hint().1;
if hint.is_some_and(|max| max >= self.options.resumable_upload_threshold as u64) {
Copy link
Member

@dbolduc dbolduc Jul 17, 2025

Choose a reason for hiding this comment

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

Q: should the default for unknown-sized objects be resumable uploads? i.e. s/is_some_and/is_none_or/

@@ -205,23 +214,84 @@ impl Seek for BytesSource {
}
}

pub struct IterSource {
Copy link
Member

Choose a reason for hiding this comment

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

is this intentionally public?

impl Seek for IterSource {
type Error = std::io::Error;
async fn seek(&mut self, offset: u64) -> std::result::Result<(), Self::Error> {
let mut current: VecDeque<_> = self.contents.iter().cloned().collect();
Copy link
Member

Choose a reason for hiding this comment

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

if this is a public type, this implementation should be more efficient. We only need to clone the chunks from contents which have already been consumed from current.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use resumable uploads for large send_buffered() / send() requests Automatically retry failed single-shot uploads
2 participants