From 5d762a8f52afeeccba7ff0dde6c26abeaa088ad7 Mon Sep 17 00:00:00 2001 From: Egor Lazarchuk Date: Tue, 17 Sep 2024 12:07:24 +0000 Subject: [PATCH] chore: update too fast benches Some benchmarks are very small and fast and this causes them to be unstable. We can still keep an eye on the performance with longer benches. Also increased number of runs and threshold. This should be fine as all tests still run in nanoseconds. Signed-off-by: Egor Lazarchuk --- src/vmm/benches/block_request.rs | 4 +- src/vmm/benches/queue.rs | 72 +------------------------------- 2 files changed, 3 insertions(+), 73 deletions(-) diff --git a/src/vmm/benches/block_request.rs b/src/vmm/benches/block_request.rs index 92989f7693b..a616a48b5bf 100644 --- a/src/vmm/benches/block_request.rs +++ b/src/vmm/benches/block_request.rs @@ -14,7 +14,7 @@ use vmm::devices::virtio::test_utils::VirtQueue; use vmm::test_utils::single_region_mem; pub fn block_request_benchmark(c: &mut Criterion) { - let mem = single_region_mem(2 * 65562); + let mem = single_region_mem(65562); let virt_queue = VirtQueue::new(GuestAddress(0), &mem, 16); // We don't really care about what request is. We just @@ -36,7 +36,7 @@ pub fn block_request_benchmark(c: &mut Criterion) { criterion_group! { name = block_request_benches; - config = Criterion::default().sample_size(200).noise_threshold(0.05); + config = Criterion::default().sample_size(1000).noise_threshold(0.05); targets = block_request_benchmark } diff --git a/src/vmm/benches/queue.rs b/src/vmm/benches/queue.rs index 168ecec33bb..faff57b2ebf 100644 --- a/src/vmm/benches/queue.rs +++ b/src/vmm/benches/queue.rs @@ -59,42 +59,6 @@ pub fn queue_benchmark(c: &mut Criterion) { let rxq = VirtQueue::new(GuestAddress(0), &mem, 256); let mut queue = rxq.create_queue(); - set_dtable_one_chain(&rxq, 1); - queue.next_avail = Wrapping(0); - let desc = queue.pop().unwrap(); - c.bench_function("next_descriptor_1", |b| { - b.iter(|| { - let mut head = Some(desc); - while let Some(d) = head { - head = std::hint::black_box(d.next_descriptor()); - } - }) - }); - - set_dtable_one_chain(&rxq, 2); - queue.next_avail = Wrapping(0); - let desc = queue.pop().unwrap(); - c.bench_function("next_descriptor_2", |b| { - b.iter(|| { - let mut head = Some(desc); - while let Some(d) = head { - head = std::hint::black_box(d.next_descriptor()); - } - }) - }); - - set_dtable_one_chain(&rxq, 4); - queue.next_avail = Wrapping(0); - let desc = queue.pop().unwrap(); - c.bench_function("next_descriptor_4", |b| { - b.iter(|| { - let mut head = Some(desc); - while let Some(d) = head { - head = std::hint::black_box(d.next_descriptor()); - } - }) - }); - set_dtable_one_chain(&rxq, 16); queue.next_avail = Wrapping(0); let desc = queue.pop().unwrap(); @@ -107,28 +71,6 @@ pub fn queue_benchmark(c: &mut Criterion) { }) }); - // Queue pop - - set_dtable_many_chains(&rxq, 1); - c.bench_function("queue_pop_1", |b| { - b.iter(|| { - queue.next_avail = Wrapping(0); - while let Some(desc) = queue.pop() { - std::hint::black_box(desc); - } - }) - }); - - set_dtable_many_chains(&rxq, 4); - c.bench_function("queue_pop_4", |b| { - b.iter(|| { - queue.next_avail = Wrapping(0); - while let Some(desc) = queue.pop() { - std::hint::black_box(desc); - } - }) - }); - set_dtable_many_chains(&rxq, 16); c.bench_function("queue_pop_16", |b| { b.iter(|| { @@ -139,18 +81,6 @@ pub fn queue_benchmark(c: &mut Criterion) { }) }); - c.bench_function("queue_add_used_1", |b| { - b.iter(|| { - queue.num_added = Wrapping(0); - queue.next_used = Wrapping(0); - for i in 0_u16..1_u16 { - let index = std::hint::black_box(i); - let len = std::hint::black_box(i + 1); - _ = queue.add_used(index as u16, len as u32); - } - }) - }); - c.bench_function("queue_add_used_16", |b| { b.iter(|| { queue.num_added = Wrapping(0); @@ -178,7 +108,7 @@ pub fn queue_benchmark(c: &mut Criterion) { criterion_group! { name = queue_benches; - config = Criterion::default().sample_size(200).noise_threshold(0.05); + config = Criterion::default().sample_size(1000).noise_threshold(0.15); targets = queue_benchmark }