Skip to content

Commit 1ab8778

Browse files
weltlingrbradford
authored andcommitted
performance-metrics: Add QCOW2 batch write micro benchmark
Add micro_bench_qcow_batch_write which builds a batch of num_ops write requests and submits them all at once through submit_batch_requests. Writes in QcowAsync are synchronous (COW path), so this measures whether batching reduces per-request overhead compared to individual write_vectored calls. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
1 parent 8052c5a commit 1ab8778

2 files changed

Lines changed: 67 additions & 1 deletion

File tree

performance-metrics/src/main.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ mod adjuster {
378378
}
379379
}
380380

381-
const TEST_LIST: [PerformanceTest; 98] = [
381+
const TEST_LIST: [PerformanceTest; 100] = [
382382
PerformanceTest {
383383
name: "boot_time_ms",
384384
func_ptr: performance_boot_time,
@@ -1685,6 +1685,30 @@ const TEST_LIST: [PerformanceTest; 98] = [
16851685
},
16861686
unit_adjuster: adjuster::s_to_us,
16871687
},
1688+
PerformanceTest {
1689+
name: "micro_block_qcow_batch_write_128_us",
1690+
func_ptr: micro_bench_block::micro_bench_qcow_batch_write,
1691+
control: PerformanceTestControl {
1692+
test_timeout: 10,
1693+
test_iterations: 20,
1694+
warmup_iterations: 5,
1695+
num_ops: Some(128),
1696+
..PerformanceTestControl::default()
1697+
},
1698+
unit_adjuster: adjuster::s_to_us,
1699+
},
1700+
PerformanceTest {
1701+
name: "micro_block_qcow_batch_write_256_us",
1702+
func_ptr: micro_bench_block::micro_bench_qcow_batch_write,
1703+
control: PerformanceTestControl {
1704+
test_timeout: 10,
1705+
test_iterations: 20,
1706+
warmup_iterations: 5,
1707+
num_ops: Some(256),
1708+
..PerformanceTestControl::default()
1709+
},
1710+
unit_adjuster: adjuster::s_to_us,
1711+
},
16881712
];
16891713

16901714
fn run_test_with_timeout(

performance-metrics/src/micro_bench_block.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,3 +549,45 @@ pub fn micro_bench_qcow_async_l2_cache_miss(control: &PerformanceTestControl) ->
549549
drain_async_completions(async_io.as_mut(), num_ops);
550550
start.elapsed().as_secs_f64()
551551
}
552+
553+
/// Measure QCOW2 batch write submission via io_uring.
554+
///
555+
/// Builds a batch of num_ops write requests and submits them all at once
556+
/// through submit_batch_requests. Writes in QcowAsync are synchronous
557+
/// (COW path), so this measures whether batching reduces per-request
558+
/// overhead compared to individual write_vectored calls.
559+
///
560+
/// Returns the total wall clock time in seconds.
561+
pub fn micro_bench_qcow_batch_write(control: &PerformanceTestControl) -> f64 {
562+
let num_ops = control.num_ops.expect("num_ops required") as usize;
563+
let (_tmp, disk) = util::empty_qcow_async_tempfile(num_ops);
564+
let mut async_io = disk
565+
.new_async_io(num_ops as u32)
566+
.expect("new_async_io failed");
567+
568+
let buf = vec![0xA5u8; num_ops * QCOW_CLUSTER_SIZE as usize];
569+
570+
let batch: Vec<BatchRequest> = (0..num_ops)
571+
.map(|i| {
572+
let slice = &buf[i * QCOW_CLUSTER_SIZE as usize..(i + 1) * QCOW_CLUSTER_SIZE as usize];
573+
BatchRequest {
574+
offset: (i as u64 * QCOW_CLUSTER_SIZE) as libc::off_t,
575+
iovecs: vec![libc::iovec {
576+
iov_base: slice.as_ptr() as *mut libc::c_void,
577+
iov_len: QCOW_CLUSTER_SIZE as usize,
578+
}]
579+
.into(),
580+
user_data: i as u64,
581+
request_type: RequestType::Out,
582+
}
583+
})
584+
.collect();
585+
586+
let start = Instant::now();
587+
async_io
588+
.submit_batch_requests(&batch)
589+
.expect("submit_batch_requests failed");
590+
591+
drain_async_completions(async_io.as_mut(), num_ops);
592+
start.elapsed().as_secs_f64()
593+
}

0 commit comments

Comments
 (0)