This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 71a9574e65 bench(arrow-ipc): add StreamDecoder benchmarks (#12093)
71a9574e65 is described below
commit 71a9574e657710383e22cfa528ecaa415a3f9a05
Author: Oleks V <[email protected]>
AuthorDate: Thu Nov 5 21:36:07 2026 +0000
bench(arrow-ipc): add StreamDecoder benchmarks (#12093)
# Which issue does this PR close?
- Relates to apache/datafusion#26687.
# Rationale for this change
`StreamDecoder` has no benchmarks. As CONTRIBUTING.md asks, this adds
them in their own PR so the benchmark runner can measure the
`StreamDecoder::with_skip_validation` fix from #11552 against `main`.
# What changes are included in this PR?
Two benchmarks next to the `StreamReader` ones, `StreamDecoder/read_10`
and `StreamDecoder/no_validation/read_10`. Both decode the same 10-batch
stream from a single `Buffer`. The code is from #11552 by @Dandandan.
# Are these changes tested?
This PR only adds benchmarks. On `main` both take about 129 µs on an M5
Max, because `with_skip_validation` does not reach record batches yet.
# Are there any significant user-facing changes?
No.
AI disclosure: The benchmarks come from #11552. Porting them to `main`
and writing this description were done with Claude Code. I have reviewed
every change and the benchmark results.
Co-authored-by: Daniël Heres <[email protected]>
---
arrow-ipc/benches/ipc_reader.rs | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/arrow-ipc/benches/ipc_reader.rs b/arrow-ipc/benches/ipc_reader.rs
index 6cf87c8505..fe806bbdd3 100644
--- a/arrow-ipc/benches/ipc_reader.rs
+++ b/arrow-ipc/benches/ipc_reader.rs
@@ -9,7 +9,7 @@ use arrow_array::types::Int32Type;
use arrow_array::{ArrayRef, FixedSizeBinaryArray, RecordBatch,
builder::StringBuilder};
use arrow_buffer::Buffer;
use arrow_ipc::convert::try_fb_to_schema;
-use arrow_ipc::reader::{FileDecoder, FileReader, StreamReader,
read_footer_length};
+use arrow_ipc::reader::{FileDecoder, FileReader, StreamDecoder, StreamReader,
read_footer_length};
use arrow_ipc::writer::{FileWriter, IpcWriteOptions, StreamWriter};
use arrow_ipc::{Block, CompressionType, root_as_footer};
use arrow_schema::{DataType, Field, Schema};
@@ -49,6 +49,33 @@ fn criterion_benchmark(c: &mut Criterion) {
})
});
+ group.bench_function("StreamDecoder/read_10", |b| {
+ let buffer = Buffer::from_vec(ipc_stream(IpcWriteOptions::default()));
+ b.iter(move || {
+ let mut decoder = StreamDecoder::new();
+ let mut buffer = buffer.clone();
+ for _ in 0..10 {
+ decoder.decode(&mut buffer).unwrap().unwrap();
+ }
+ assert!(decoder.decode(&mut buffer).unwrap().is_none());
+ decoder.finish().unwrap();
+ })
+ });
+
+ group.bench_function("StreamDecoder/no_validation/read_10", |b| {
+ let buffer = Buffer::from_vec(ipc_stream(IpcWriteOptions::default()));
+ b.iter(move || {
+ // safety: we created a valid IPC stream
+ let mut decoder = unsafe {
StreamDecoder::new().with_skip_validation(true) };
+ let mut buffer = buffer.clone();
+ for _ in 0..10 {
+ decoder.decode(&mut buffer).unwrap().unwrap();
+ }
+ assert!(decoder.decode(&mut buffer).unwrap().is_none());
+ decoder.finish().unwrap();
+ })
+ });
+
group.bench_function("StreamReader/read_10/zstd", |b| {
let buffer = ipc_stream(
IpcWriteOptions::default()