mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
performance-metrics: Add qcow2 punch hole micro benchmark
Add micro_bench_qcow_punch_hole which times punch_hole calls through QcowSync on a prepopulated qcow2 image. Each call deallocates one cluster exercising deallocate_bytes with refcount decrement and fallocate punch_hole on the host file. Two TEST_LIST entries: micro_block_qcow_punch_hole_64_us and micro_block_qcow_punch_hole_256_us with 64 and 256 cluster workloads. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
f7e40eec9a
commit
c3312dca3f
@@ -106,3 +106,29 @@ pub fn micro_bench_qcow_write(control: &PerformanceTestControl) -> f64 {
|
||||
|
||||
elapsed
|
||||
}
|
||||
|
||||
/// Punch holes for num_ops clusters in a prepopulated qcow2 image through
|
||||
/// the QcowSync async_io path and time the total punch_hole wall clock.
|
||||
///
|
||||
/// This exercises the discard path: deallocate_bytes decrements refcounts,
|
||||
/// frees clusters and issues fallocate punch_hole on the host file.
|
||||
///
|
||||
/// Returns the total punch_hole wall clock time in seconds.
|
||||
pub fn micro_bench_qcow_punch_hole(control: &PerformanceTestControl) -> f64 {
|
||||
let num_ops = control.num_ops.expect("num_ops required") as usize;
|
||||
let (_tmp, disk) = util::qcow_tempfile(num_ops);
|
||||
let mut async_io = disk.new_async_io(1).expect("new_async_io failed");
|
||||
|
||||
let start = Instant::now();
|
||||
for i in 0..num_ops {
|
||||
async_io
|
||||
.punch_hole(i as u64 * QCOW_CLUSTER_SIZE, QCOW_CLUSTER_SIZE, i as u64)
|
||||
.expect("punch_hole failed");
|
||||
}
|
||||
let elapsed = start.elapsed().as_secs_f64();
|
||||
|
||||
// Drain completions so Drop is clean.
|
||||
drain_completions(async_io.as_mut(), num_ops);
|
||||
|
||||
elapsed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user