This is an automated email from the ASF dual-hosted git repository.
Xuanwo 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 6f1ac56a61 docs: clarify reader prefetch scheduling (#9384)
6f1ac56a61 is described below
commit 6f1ac56a614b46713f2b9f83479b461cb95248a1
Author: Xuanwo <[email protected]>
AuthorDate: Mon Nov 30 00:21:11 2026 +0800
docs: clarify reader prefetch scheduling (#9384)
---
bindings/c/include/opendal.h | 14 ++++++++++++--
bindings/c/src/types.rs | 14 ++++++++++++--
bindings/go/reader.go | 10 +++++++++-
.../java/org/apache/opendal/ReaderOptions.java | 10 ++++++++--
bindings/nodejs/generated.d.ts | 17 +++++++----------
bindings/nodejs/src/options/reader.rs | 17 +++++++----------
core/core/src/types/options.rs | 17 +++++++----------
dev/src/generate/java.rs | 22 +++++++++++++---------
website/docs/20-bindings/java/04-tasks.md | 15 +++++++++++----
9 files changed, 86 insertions(+), 50 deletions(-)
diff --git a/bindings/c/include/opendal.h b/bindings/c/include/opendal.h
index 230dcc06a7..a553b16774 100644
--- a/bindings/c/include/opendal.h
+++ b/bindings/c/include/opendal.h
@@ -734,7 +734,15 @@ typedef struct opendal_reader_options {
*/
uintptr_t gap;
/**
- * Number of prefetched byte ranges buffered during concurrent reads.
+ * Read-ahead allowance for concurrent chunked reads.
+ *
+ * Up to `prefetch` finished reads can each free a slot for another range
+ * read before OpenDAL collects their results. Zero (the default) disables
+ * these extra slots. Reads already submitted under `concurrent` can still
+ * finish and wait to be collected.
+ *
+ * Serial reads collect each result before starting the next read. Higher
+ * values can increase memory use.
*/
uintptr_t prefetch;
} opendal_reader_options;
@@ -4034,7 +4042,9 @@ void opendal_reader_options_set_chunk(struct
opendal_reader_options *opts, uintp
void opendal_reader_options_set_gap(struct opendal_reader_options *opts,
uintptr_t gap);
/**
- * \brief Set the number of prefetched byte ranges buffered during concurrent
reads.
+ * \brief Set the read-ahead allowance for concurrent chunked reads.
+ *
+ * @see opendal_reader_options::prefetch
*/
void opendal_reader_options_set_prefetch(struct opendal_reader_options *opts,
uintptr_t prefetch);
diff --git a/bindings/c/src/types.rs b/bindings/c/src/types.rs
index 15c2354716..060c9f5f47 100644
--- a/bindings/c/src/types.rs
+++ b/bindings/c/src/types.rs
@@ -335,7 +335,15 @@ pub struct opendal_reader_options {
pub has_gap: bool,
/// Gap size for merging nearby range reads.
pub gap: usize,
- /// Number of prefetched byte ranges buffered during concurrent reads.
+ /// Read-ahead allowance for concurrent chunked reads.
+ ///
+ /// Up to `prefetch` finished reads can each free a slot for another range
+ /// read before OpenDAL collects their results. Zero (the default) disables
+ /// these extra slots. Reads already submitted under `concurrent` can still
+ /// finish and wait to be collected.
+ ///
+ /// Serial reads collect each result before starting the next read. Higher
+ /// values can increase memory use.
pub prefetch: usize,
}
@@ -484,7 +492,9 @@ impl opendal_reader_options {
}
}
- /// \brief Set the number of prefetched byte ranges buffered during
concurrent reads.
+ /// \brief Set the read-ahead allowance for concurrent chunked reads.
+ ///
+ /// @see opendal_reader_options::prefetch
#[no_mangle]
pub unsafe extern "C" fn opendal_reader_options_set_prefetch(
opts: *mut opendal_reader_options,
diff --git a/bindings/go/reader.go b/bindings/go/reader.go
index 8593667f67..23c9910532 100644
--- a/bindings/go/reader.go
+++ b/bindings/go/reader.go
@@ -174,7 +174,15 @@ func ReaderWithGap(gap uint) WithReaderFn {
}
}
-// ReaderWithPrefetch sets the number of prefetched byte ranges buffered
during concurrent reads.
+// ReaderWithPrefetch sets the read-ahead allowance for concurrent chunked
reads.
+//
+// Up to prefetch finished reads can each free a slot for another range read
+// before OpenDAL collects their results. Zero (the default) disables these
+// extra slots. Reads already submitted under the [ReaderWithConcurrent]
+// setting can still finish and wait to be collected.
+//
+// Serial reads collect each result before starting the next read. Higher
+// values can increase memory use.
func ReaderWithPrefetch(prefetch uint) WithReaderFn {
return func(o *readerOptions) {
o.prefetch = prefetch
diff --git a/bindings/java/src/main/java/org/apache/opendal/ReaderOptions.java
b/bindings/java/src/main/java/org/apache/opendal/ReaderOptions.java
index 7ccef6828b..324f5ad42f 100644
--- a/bindings/java/src/main/java/org/apache/opendal/ReaderOptions.java
+++ b/bindings/java/src/main/java/org/apache/opendal/ReaderOptions.java
@@ -130,9 +130,15 @@ public final class ReaderOptions {
public final long chunk = -1L;
/**
- * Controls the number of prefetched bytes ranges that can be buffered in
memory during concurrent reading.
+ * Controls read-ahead during concurrent range reads.
*
- * <p>This option counts completed chunks buffered ahead of consumption,
regardless of their size in bytes. The default of {@code 0} applies strict
backpressure. Negative values fail with {@link
OpenDALException.Code#ConfigInvalid}. This setting applies only to chunked
reads enabled by {@link #chunk}.
+ * <p>Up to {@code prefetch} finished reads can each free a slot for
another range read before OpenDAL collects their results.
+ *
+ * <p>The default, {@code 0}, disables these extra slots. Reads already
submitted under {@link #concurrent} can still finish and wait to be collected.
+ *
+ * <p>Serial reads collect each result before starting the next read.
Higher values can increase memory use.
+ *
+ * <p>This setting applies only to chunked reads enabled by {@link
#chunk}. Negative values fail with {@link OpenDALException.Code#ConfigInvalid}.
*/
@Builder.Default
public final int prefetch = 0;
diff --git a/bindings/nodejs/generated.d.ts b/bindings/nodejs/generated.d.ts
index a4e9ec7267..c933d5efe0 100644
--- a/bindings/nodejs/generated.d.ts
+++ b/bindings/nodejs/generated.d.ts
@@ -1386,19 +1386,16 @@ export interface ReaderOptions {
*/
chunk?: number
/**
- * Controls the number of prefetched bytes ranges that can be buffered in
memory
- * during concurrent reading.
+ * Controls read-ahead during concurrent range reads.
*
- * When performing concurrent reads with `Reader`, this option limits how
many
- * completed-but-not-yet-read chunks can be buffered. Once the number of
buffered
- * chunks reaches this limit, no new read tasks will be spawned until some
of the
- * buffered chunks are consumed.
+ * Up to `prefetch` finished reads can each free a slot for another range
+ * read before OpenDAL collects their results.
*
- * - Default value: 0 (no prefetching, strict back-pressure control)
- * - Set to a higher value to allow more aggressive prefetching at the cost
of memory
+ * The default, `0`, disables these extra slots. Reads already submitted
+ * under `concurrent` can still finish and wait to be collected.
*
- * This option helps prevent memory exhaustion when reading large files with
high
- * concurrency settings.
+ * Serial reads collect each result before starting the next read. Higher
+ * values can increase memory use.
*/
prefetch?: number
/**
diff --git a/bindings/nodejs/src/options/reader.rs
b/bindings/nodejs/src/options/reader.rs
index 3b316f9838..196172bde7 100644
--- a/bindings/nodejs/src/options/reader.rs
+++ b/bindings/nodejs/src/options/reader.rs
@@ -75,19 +75,16 @@ pub struct ReaderOptions {
/// an error whose message includes `Unsupported`.
pub chunk: Option<u32>,
- /// Controls the number of prefetched bytes ranges that can be buffered in
memory
- /// during concurrent reading.
+ /// Controls read-ahead during concurrent range reads.
///
- /// When performing concurrent reads with `Reader`, this option limits how
many
- /// completed-but-not-yet-read chunks can be buffered. Once the number of
buffered
- /// chunks reaches this limit, no new read tasks will be spawned until
some of the
- /// buffered chunks are consumed.
+ /// Up to `prefetch` finished reads can each free a slot for another range
+ /// read before OpenDAL collects their results.
///
- /// - Default value: 0 (no prefetching, strict back-pressure control)
- /// - Set to a higher value to allow more aggressive prefetching at the
cost of memory
+ /// The default, `0`, disables these extra slots. Reads already submitted
+ /// under `concurrent` can still finish and wait to be collected.
///
- /// This option helps prevent memory exhaustion when reading large files
with high
- /// concurrency settings.
+ /// Serial reads collect each result before starting the next read. Higher
+ /// values can increase memory use.
pub prefetch: Option<u32>,
/// Readers returned by `reader()` and `readerSync()` read the whole file
as one range, so
diff --git a/core/core/src/types/options.rs b/core/core/src/types/options.rs
index 5137b3d16d..9ac3acf260 100644
--- a/core/core/src/types/options.rs
+++ b/core/core/src/types/options.rs
@@ -544,19 +544,16 @@ pub struct ReaderOptions {
/// Refer to the [performance
guide](https://github.com/apache/opendal/tree/main/core/core/src/docs/performance)
/// for more details.
pub gap: Option<usize>,
- /// Controls the number of prefetched bytes ranges that can be buffered in
memory
- /// during concurrent reading.
+ /// Controls read-ahead during concurrent range reads.
///
- /// When performing concurrent reads with `Reader`, this option limits how
many
- /// completed-but-not-yet-read chunks can be buffered. Once the number of
buffered
- /// chunks reaches this limit, no new read tasks will be spawned until
some of the
- /// buffered chunks are consumed.
+ /// Up to `prefetch` finished reads can each free a slot for another range
+ /// read before OpenDAL collects their results.
///
- /// - Default value: 0 (no prefetching, strict back-pressure control)
- /// - Set to a higher value to allow more aggressive prefetching at the
cost of memory
+ /// The default, `0`, disables these extra slots. Reads already submitted
+ /// under `concurrent` can still finish and wait to be collected.
///
- /// This option helps prevent memory exhaustion when reading large files
with high
- /// concurrency settings.
+ /// Serial reads collect each result before starting the next read. Higher
+ /// values can increase memory use.
pub prefetch: usize,
/// Request full-file checksum metadata for reads through this reader.
diff --git a/dev/src/generate/java.rs b/dev/src/generate/java.rs
index f6f7a33fe5..3ce10858c6 100644
--- a/dev/src/generate/java.rs
+++ b/dev/src/generate/java.rs
@@ -839,12 +839,13 @@ fn option_field_javadoc(
"Application transfer and Java thread counts are independent
of this setting."
).to_owned());
}
- ("ReaderOptions", "prefetch") => details.push(concat!(
- "This option counts completed chunks buffered ahead of
consumption, regardless of their size in bytes. ",
- "The default of {@code 0} applies strict backpressure. Negative
values fail with ",
- "{@link OpenDALException.Code#ConfigInvalid}. This setting applies
only to ",
- "chunked reads enabled by {@link #chunk}."
- ).to_owned()),
+ ("ReaderOptions", "prefetch") => {
+ details.extend(paragraphs().skip(1).filter(|paragraph|
!paragraph.is_empty()).map(render));
+ details.push(concat!(
+ "This setting applies only to chunked reads enabled by {@link
#chunk}. ",
+ "Negative values fail with {@link
OpenDALException.Code#ConfigInvalid}."
+ ).to_owned());
+ }
("ReadOptions" | "ReaderOptions", "content_length_hint") =>
details.extend([
concat!(
"Supply the full object length in bytes, regardless of the
requested range. ",
@@ -1512,10 +1513,13 @@ mod tests {
assert_field(
"prefetch",
&[
- "counts completed chunks buffered ahead of
consumption, regardless of their size in bytes",
- "{@code 0} applies strict backpressure",
- "Negative values fail with {@link
OpenDALException.Code#ConfigInvalid}",
+ "Up to {@code prefetch} finished reads can
each free a slot for another range read before OpenDAL collects their results.",
+ "The default, {@code 0}, disables these extra
slots.",
+ "Reads already submitted under {@link
#concurrent} can still finish and wait to be collected.",
+ "Serial reads collect each result before
starting the next read.",
+ "Higher values can increase memory use.",
"chunked reads enabled by {@link #chunk}",
+ "Negative values fail with {@link
OpenDALException.Code#ConfigInvalid}",
],
);
}
diff --git a/website/docs/20-bindings/java/04-tasks.md
b/website/docs/20-bindings/java/04-tasks.md
index 97133f6bdf..97220d8739 100644
--- a/website/docs/20-bindings/java/04-tasks.md
+++ b/website/docs/20-bindings/java/04-tasks.md
@@ -78,10 +78,17 @@ try (OperatorReader reader =
op.createReader("path/to/file", options)) {
}
```
-A positive `chunk` enables internal range requests; `concurrent` limits those
-requests and `prefetch` counts completed chunks buffered ahead. Setting
-`concurrent` alone keeps unchunked streaming. A reader does not snapshot the
-file, so subsequent reads may observe changes.
+A positive `chunk` enables internal range requests, and `concurrent` limits
+how many run in parallel. Setting `concurrent` alone keeps unchunked streaming.
+
+During concurrent chunked reads, `prefetch` lets up to that many finished
+reads free slots for additional requests before OpenDAL collects their
+results. The default, `0`, disables these extra slots. Reads already
+submitted can still finish and wait to be collected. Serial reads collect
+each result before starting the next read. Higher values can increase memory
+use.
+
+A reader does not snapshot the file, so subsequent reads may observe changes.
`ReaderOptions` omits `gap` because Java does not expose multi-range reads.