adjust bench for both sync and async benchmarking

This commit is contained in:
Christian Schwarz
2024-04-09 10:46:10 +00:00
parent b44bbd276e
commit afd2c1369e
3 changed files with 33 additions and 27 deletions

View File

@@ -45,33 +45,39 @@ use tokio::{sync::Barrier, task::JoinSet};
use utils::{id::TenantId, lsn::Lsn};
fn bench(c: &mut Criterion) {
{
let nclients = [1, 2, 4, 8, 16, 32, 64, 128];
for nclients in nclients {
let mut group = c.benchmark_group("short");
group.bench_with_input(
BenchmarkId::from_parameter(nclients),
&nclients,
|b, nclients| {
let redo_work = Arc::new(Request::short_input());
b.iter_custom(|iters| bench_impl(Arc::clone(&redo_work), iters, *nclients));
},
);
for process_kind in &[
pageserver::walredo::ProcessKind::Async,
pageserver::walredo::ProcessKind::Sync,
] {
pageserver::walredo::set_process_kind(*process_kind);
{
let nclients = [1, 2, 4, 8, 16, 32, 64, 128];
for nclients in nclients {
let mut group = c.benchmark_group(format!("{process_kind}-short"));
group.bench_with_input(
BenchmarkId::from_parameter(nclients),
&nclients,
|b, nclients| {
let redo_work = Arc::new(Request::short_input());
b.iter_custom(|iters| bench_impl(Arc::clone(&redo_work), iters, *nclients));
},
);
}
}
}
{
let nclients = [1, 2, 4, 8, 16, 32, 64, 128];
for nclients in nclients {
let mut group = c.benchmark_group("medium");
group.bench_with_input(
BenchmarkId::from_parameter(nclients),
&nclients,
|b, nclients| {
let redo_work = Arc::new(Request::medium_input());
b.iter_custom(|iters| bench_impl(Arc::clone(&redo_work), iters, *nclients));
},
);
{
let nclients = [1, 2, 4, 8, 16, 32, 64, 128];
for nclients in nclients {
let mut group = c.benchmark_group(format!("{process_kind}-medium"));
group.bench_with_input(
BenchmarkId::from_parameter(nclients),
&nclients,
|b, nclients| {
let redo_work = Arc::new(Request::medium_input());
b.iter_custom(|iters| bench_impl(Arc::clone(&redo_work), iters, *nclients));
},
);
}
}
}
}

View File

@@ -20,7 +20,7 @@
/// Process lifecycle and abstracction for the IPC protocol.
mod process;
pub(crate) use process::{set_kind as set_process_kind, Kind as ProcessKind};
pub use process::{set_kind as set_process_kind, Kind as ProcessKind};
/// Code to apply [`NeonWalRecord`]s.
pub(crate) mod apply_neon;

View File

@@ -55,7 +55,7 @@ impl Kind {
static PROCESS_KIND: AtomicU8 = AtomicU8::new(Kind::DEFAULT as u8);
pub(crate) fn set_kind(kind: Kind) {
pub fn set_kind(kind: Kind) {
PROCESS_KIND.store(kind as u8, std::sync::atomic::Ordering::Relaxed);
#[cfg(not(test))]
{