Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions arrow-flight/benches/flight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if it also made sense to benchmark decoding more than one batch (for example, a stream with replacement dictionary) but I think for now this is good

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a follow up PR for that here #10207 🚀

.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());
Expand Down Expand Up @@ -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
);
Expand Down
Loading