From bd5dcd8d3ca717c0e77d25e040bcd8771ff49369 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Sun, 14 Sep 2025 15:57:23 -0300 Subject: [PATCH] add timeout flag to throughput benchmark --- perf/throughput/turso/src/main.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/perf/throughput/turso/src/main.rs b/perf/throughput/turso/src/main.rs index 34cfc3576..8679d2666 100644 --- a/perf/throughput/turso/src/main.rs +++ b/perf/throughput/turso/src/main.rs @@ -1,7 +1,7 @@ use clap::{Parser, ValueEnum}; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Arc, Barrier}; -use std::time::Instant; +use std::time::{Duration, Instant}; use turso::{Builder, Database, Result}; #[derive(Debug, Clone, Copy, ValueEnum)] @@ -33,6 +33,13 @@ struct Args { help = "Per transaction think time (ms)" )] think: u64, + + #[arg( + long = "timeout", + default_value = "50", + help = "Busy timeout in milliseconds" + )] + timeout: u64, } #[tokio::main] @@ -58,6 +65,8 @@ async fn main() -> Result<()> { let start_barrier = Arc::new(Barrier::new(args.threads)); let mut handles = Vec::new(); + let timeout = Duration::from_millis(args.timeout); + let overall_start = Instant::now(); for thread_id in 0..args.threads { @@ -72,6 +81,7 @@ async fn main() -> Result<()> { barrier, args.mode, args.think, + timeout, )); handles.push(handle); @@ -137,6 +147,7 @@ async fn setup_database(db_path: &str, mode: TransactionMode) -> Result, mode: TransactionMode, think_ms: u64, + timeout: Duration, ) -> Result { start_barrier.wait(); @@ -155,7 +167,7 @@ async fn worker_thread( for iteration in 0..iterations { let conn = db.connect()?; - conn.busy_timeout(Some(std::time::Duration::from_millis(10)))?; + conn.busy_timeout(Some(timeout))?; let total_inserts = Arc::clone(&total_inserts); let tx_fut = async move { let mut stmt = conn