fix: ensure a maximum of buffer_len RecordBatches are cached in spawn_buffered#23560
Conversation
buffer_len RecordBatches are cached in spawn_buffered
|
run benchmarks |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing fix-23559 (cc4945a) to 79692c1 (merge-base) diff using: tpch File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing fix-23559 (cc4945a) to 79692c1 (merge-base) diff using: clickbench_partitioned File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing fix-23559 (cc4945a) to 79692c1 (merge-base) diff using: tpcds File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usagetpch — base (merge-base)
tpch — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usagetpcds — base (merge-base)
tpcds — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usageclickbench_partitioned — base (merge-base)
clickbench_partitioned — branch
File an issue against this benchmark runner |
| use std::sync::atomic::{AtomicUsize, Ordering}; | ||
|
|
||
| let schema = Arc::new(Schema::new(vec![Field::new("a", DataType::Int32, false)])); | ||
| let buffer_size = 1; |
There was a problem hiding this comment.
can you have the same test but with buffer_size 2 as well? (just extract the test code and get an argument for buffer_size)
| // With reserve(), the producer acquires a channel slot before pulling from | ||
| // input, so at most buffer_size batches can exist in memory simultaneously. |
There was a problem hiding this comment.
this (reserve call) refer to current code that can become outdated and then this comment will be confusing.
| while let Ok(permit) = sender.reserve().await { | ||
| // Receiver dropped when query is shutdown early (e.g., limit) or error, | ||
| // no need to return propagate the send error. | ||
| match input.next().await { | ||
| Some(item) => permit.send(item), | ||
| None => break, | ||
| } |
There was a problem hiding this comment.
Please add the comment for the reserve here rather than in the test code.
something like
/// We call `reserve` (which wait to have capacity of at least 1 message in the channel buffer) **before** polling from input
/// since if we first polled from input and then wait for the channel to have capacity for the message we will essentially hold `buffer` (in the channel) + 1 (waiting for the channel to have capacity)
Which issue does this PR close?
Fixes: #23559
Rationale for this change
See the issue description
What changes are included in this PR?
Change spawn_buffered's behavior to ensure a maximum of
bufferRecordBatches are produced before any consumer polls the stream.Are these changes tested?
Yes
Are there any user-facing changes?
No