This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-12316-33fd4cdb617c3c62762017a5f61de02311a380ee in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit eb62e55752b8376bcedc926e2e37547828ec82f9 Author: Gabriel <[email protected]> AuthorDate: Wed Nov 18 16:16:40 2026 +0000 bench(arrow-ipc): add lz4 decompression benchmarks for IPC reader (#12316) Adds some new benches for helping qualify a future change in https://github.com/apache/arrow-rs/pull/12317. The new benchmarks are some `StreamReader` cases using `CompressionType::LZ4_FRAME`, including single-threaded and multi-threaded (contended) variants, with both small and large batches. --- arrow-ipc/benches/ipc_reader.rs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/arrow-ipc/benches/ipc_reader.rs b/arrow-ipc/benches/ipc_reader.rs index fe806bbdd3..4b6fa163bb 100644 --- a/arrow-ipc/benches/ipc_reader.rs +++ b/arrow-ipc/benches/ipc_reader.rs @@ -108,6 +108,34 @@ fn criterion_benchmark(c: &mut Criterion) { }) }); + for (rows, threads) in [(256, 1), (8192, 1), (256, 16), (8192, 16)] { + group.bench_function( + format!("StreamReader/read_10/lz4/rows={rows}/threads={threads}"), + |b| { + let buffer = ipc_stream_with_rows( + rows, + IpcWriteOptions::default() + .try_with_compression(Some(CompressionType::LZ4_FRAME)) + .unwrap(), + ); + b.iter(|| { + std::thread::scope(|s| { + for _ in 0..threads { + s.spawn(|| { + let mut reader = + StreamReader::try_new(buffer.as_slice(), None).unwrap(); + for _ in 0..10 { + reader.next().unwrap().unwrap(); + } + assert!(reader.next().is_none()); + }); + } + }) + }) + }, + ); + } + group.bench_function("StreamReader/no_validation/read_10/zstd", |b| { let buffer = ipc_stream( IpcWriteOptions::default() @@ -252,7 +280,12 @@ fn dictionary_ipc_stream(num_columns: usize, num_distinct: usize, list: bool) -> /// Return an IPC stream with 10 record batches fn ipc_stream(options: IpcWriteOptions) -> Vec<u8> { - let batch = create_batch(8192, true); + ipc_stream_with_rows(8192, options) +} + +/// Return an IPC stream with 10 record batches of `rows` rows each +fn ipc_stream_with_rows(rows: usize, options: IpcWriteOptions) -> Vec<u8> { + let batch = create_batch(rows, true); let mut buffer = Vec::with_capacity(2 * 1024 * 1024); let mut writer = StreamWriter::try_new_with_options(&mut buffer, batch.schema().as_ref(), options).unwrap();
