This is an automated email from the ASF dual-hosted git repository.

alamb 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 006c59f429 introduce decode benchmarks (#10202)
006c59f429 is described below

commit 006c59f429d227b2f5f72939949f56f29ef0d288
Author: RIchard Baah <[email protected]>
AuthorDate: Tue Jun 23 15:38:30 2026 -0400

    introduce decode benchmarks (#10202)
    
    # Which issue does this PR close?
    
    <!--
    We generally require a GitHub issue to be filed for all bug fixes and
    enhancements and this helps us generate change logs for our releases.
    You can link an issue to this PR using the GitHub syntax.
    -->
    
    - works towards  #10125 & works with #10137.
    
    # Rationale for this change
    there were no benchmarks for the decode path
    
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand
    your changes and offer better suggestions for fixes.
    -->
    
    # What changes are included in this PR?
    single benchmark that measures the time it takes to decode a stream of
    `flight_data`
    <!--
    There is no need to duplicate the description in the issue here but it
    is sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    
    # Are these changes tested?
    n/a
    <!--
    We typically require tests for all PRs in order to:
    1. Prevent the code from being accidentally broken by subsequent changes
    2. Serve as another way to document the expected behavior of the code
    
    If tests are not included in your PR, please explain why (for example,
    are they covered by existing tests)?
    
    If this PR claims a performance improvement, please include evidence
    such as benchmark results.
    -->
    
    # Are there any user-facing changes?
    
    <!--
    If there are user-facing changes then we may require documentation to be
    updated before approving the PR.
    
    If there are any breaking changes to public APIs, please call them out.
    -->
    no
---
 arrow-flight/benches/flight.rs | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/arrow-flight/benches/flight.rs b/arrow-flight/benches/flight.rs
index db03380bb0..3519b8e133 100644
--- a/arrow-flight/benches/flight.rs
+++ b/arrow-flight/benches/flight.rs
@@ -18,6 +18,7 @@
 use arrow_array::RecordBatch;
 use arrow_flight::{
     FlightClient, FlightData,
+    decode::FlightRecordBatchStream,
     encode::{DictionaryHandling, FlightDataEncoderBuilder},
 };
 use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, 
criterion_main};
@@ -66,6 +67,43 @@ async fn roundtrip(channel: Channel, batch: RecordBatch) {
         .unwrap();
 }
 
+fn bench_decode(c: &mut Criterion) {
+    let rt = tokio::runtime::Runtime::new().unwrap();
+    let mut g = c.benchmark_group("decode");
+
+    for &(name, build) in TYPES {
+        for &rows in &ROWS {
+            for &cols in &COLS {
+                let batch = build_batch(name, rows, cols, build);
+                let frames: Vec<FlightData> = rt
+                    .block_on(
+                        FlightDataEncoderBuilder::new()
+                            .build(futures::stream::iter([Ok(batch.clone())]))
+                            .try_collect(),
+                    )
+                    .unwrap();
+                let id = BenchmarkId::new(name, format!("{rows}x{cols}"));
+                g.throughput(Throughput::Bytes(batch.get_array_memory_size() 
as u64));
+                g.bench_function(id, |b| {
+                    b.to_async(&rt).iter_batched(
+                        || frames.clone(),
+                        |frames| async move {
+                            let _: Vec<RecordBatch> =
+                                FlightRecordBatchStream::new_from_flight_data(
+                                    
futures::stream::iter(frames.into_iter().map(Ok)),
+                                )
+                                .try_collect()
+                                .await
+                                .unwrap();
+                        },
+                        criterion::BatchSize::SmallInput,
+                    );
+                });
+            }
+        }
+    }
+}
+
 fn bench_roundtrip(c: &mut Criterion) {
     let rt = tokio::runtime::Runtime::new().unwrap();
     let (channel, _) = rt.block_on(start_server());
@@ -134,6 +172,7 @@ fn bench_do_put_dictionary(c: &mut Criterion) {
 criterion_group!(
     benches,
     bench_encode,
+    bench_decode,
     bench_roundtrip,
     bench_do_put_dictionary
 );

Reply via email to