This is an automated email from the ASF dual-hosted git repository.
tisonkun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 8090e8e65c feat(integrations/object_store): expose multipart chunk
size and concurrency (#8445)
8090e8e65c is described below
commit 8090e8e65cac2c582d2b70278667c231613e3187
Author: dentiny <[email protected]>
AuthorDate: Sun Nov 15 19:26:16 2026 -0800
feat(integrations/object_store): expose multipart chunk size and
concurrency (#8445)
---
integrations/object_store/README.md | 26 ++++++++++++++++
integrations/object_store/src/store.rs | 57 +++++++++++++++++++++++++++++++++-
2 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/integrations/object_store/README.md
b/integrations/object_store/README.md
index 0c8f3d70ce..2c16d04d2b 100644
--- a/integrations/object_store/README.md
+++ b/integrations/object_store/README.md
@@ -101,6 +101,32 @@ ranges are still merged without over-fetching. Set an
intermediate value to trad
fewer backend requests for additional bytes read. A gap of `0` can be useful
for
HDFS scans that are sensitive to retaining large coalesced backing buffers.
+### Tune multipart uploads
+
+Set the buffered chunk size in bytes and the concurrency per multipart upload
+when constructing the store:
+
+```rust
+let object_store = OpendalStore::new(operator)
+ .with_multipart_chunk_size(16 * 1024 * 1024)
+ .with_multipart_concurrency(4);
+```
+
+Both settings apply to multipart uploads, including `put_multipart` and
+`put_multipart_opts`. They do not affect `put` or `put_opts`. Without an
explicit
+chunk size, OpenDAL continues to choose it from the service's capabilities.
OpenDAL clamps an explicit size to the service's minimum and
+maximum multipart sizes, and the final chunk may be smaller. The size must be
+nonzero; passing zero panics.
+
+Larger chunks reduce backend requests per byte uploaded, at the cost of more
+buffered memory and more data to retransmit after a failed request.
+
+Upload concurrency defaults to 8. Set it to 1 for sequential writes. Higher
+concurrency can improve throughput at the cost of more buffered memory.
Services
+that do not support concurrent writes continue to write sequentially.
Concurrency
+must be nonzero; passing zero panics. This setting does not affect ordinary
puts
+or reads.
+
## WASM support
To build with `wasm32-unknown-unknown` target, you need to enable the
`send_wrapper` feature:
diff --git a/integrations/object_store/src/store.rs
b/integrations/object_store/src/store.rs
index 28a392a3af..dabbb29fe7 100644
--- a/integrations/object_store/src/store.rs
+++ b/integrations/object_store/src/store.rs
@@ -183,6 +183,8 @@ pub struct OpendalStore {
info: Arc<OperatorInfo>,
inner: Operator,
get_ranges_gap: usize,
+ multipart_chunk_size: Option<usize>,
+ multipart_concurrency: usize,
}
impl OpendalStore {
@@ -192,6 +194,8 @@ impl OpendalStore {
info: op.info().into(),
inner: op,
get_ranges_gap: DEFAULT_GET_RANGES_GAP,
+ multipart_chunk_size: None,
+ multipart_concurrency: DEFAULT_CONCURRENT,
}
}
@@ -205,6 +209,56 @@ impl OpendalStore {
self
}
+ /// Set the buffered chunk size, in bytes, for multipart uploads.
+ ///
+ /// By default, OpenDAL chooses the chunk size from the service's
capabilities.
+ /// This setting applies to [`ObjectStore::put_multipart_opts`] and the
+ /// convenience multipart APIs, but not to [`ObjectStore::put_opts`].
+ /// OpenDAL clamps the size to the service's minimum and maximum multipart
+ /// sizes. The final chunk may be smaller. Upload concurrency is unchanged.
+ /// Larger chunks reduce write requests but increase buffering and the
amount
+ /// of data retransmitted when a request fails.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `chunk_size` is zero.
+ ///
+ /// ```
+ /// # use object_store_opendal::OpendalStore;
+ /// # use opendal::{Operator, services::Memory};
+ /// # let operator = Operator::new(Memory::default()).unwrap();
+ /// let store = OpendalStore::new(operator)
+ /// .with_multipart_chunk_size(16 * 1024 * 1024)
+ /// .with_multipart_concurrency(4);
+ /// ```
+ pub fn with_multipart_chunk_size(mut self, chunk_size: usize) -> Self {
+ assert!(
+ chunk_size > 0,
+ "multipart chunk size must be greater than zero"
+ );
+ self.multipart_chunk_size = Some(chunk_size);
+ self
+ }
+
+ /// Set the maximum concurrent writes for each multipart upload.
+ ///
+ /// Defaults to 8. Set to 1 for sequential writes. Higher values can
improve
+ /// throughput at the cost of more buffered memory. Services that do not
+ /// support concurrent writes continue to write sequentially.
+ /// This setting does not affect ordinary puts or reads.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `concurrency` is zero.
+ pub fn with_multipart_concurrency(mut self, concurrency: usize) -> Self {
+ assert!(
+ concurrency > 0,
+ "multipart concurrency must be greater than zero"
+ );
+ self.multipart_concurrency = concurrency;
+ self
+ }
+
/// Get the Operator info.
pub fn info(&self) -> &OperatorInfo {
self.info.as_ref()
@@ -485,7 +539,8 @@ impl ObjectStore for OpendalStore {
opts: PutMultipartOptions,
) -> object_store::Result<Box<dyn MultipartUpload>> {
let mut options = opendal::options::WriteOptions {
- concurrent: DEFAULT_CONCURRENT,
+ concurrent: self.multipart_concurrency,
+ chunk: self.multipart_chunk_size,
..Default::default()
};