From 44e40b28168f5ef04373ce887c1da01744f09794 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Wed, 29 Oct 2025 06:54:21 -0700 Subject: [PATCH] fixup! benchmark --- benches/any/pool.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/benches/any/pool.rs b/benches/any/pool.rs index a6890580..423b2ce0 100644 --- a/benches/any/pool.rs +++ b/benches/any/pool.rs @@ -9,7 +9,7 @@ use tracing::Instrument; struct Input { threads: usize, tasks: usize, - pool_size: u32, + pool_size: usize, } impl Display for Input { @@ -24,6 +24,7 @@ impl Display for Input { fn bench_pool(c: &mut Criterion) { sqlx::any::install_default_drivers(); + tracing_subscriber::fmt::try_init().ok(); let database_url = dotenvy::var("DATABASE_URL").expect("DATABASE_URL must be set"); @@ -72,6 +73,14 @@ fn bench_pool(c: &mut Criterion) { } fn bench_pool_with(b: &mut Bencher, input: &Input, database_url: &str) { + let _span = tracing::info_span!( + "bench_pool_with", + threads = input.threads, + tasks = input.tasks, + pool_size = input.pool_size + ) + .entered(); + let runtime = tokio::runtime::Builder::new_multi_thread() .enable_all() .worker_threads(input.threads) @@ -88,10 +97,13 @@ fn bench_pool_with(b: &mut Bencher, input: &Input, database_url: &str) { .expect("error connecting to pool") }); - for _ in 1..=input.tasks { + for num in 1..=input.tasks { let pool = pool.clone(); - runtime.spawn(async move { while pool.acquire().await.is_ok() {} }); + runtime.spawn( + async move { while pool.acquire().await.is_ok() {} } + .instrument(tracing::info_span!("task", num)), + ); } // Spawn the benchmark loop into the runtime so we're not accidentally including the main thread