From 529770bf32021ba4a4da2082810e956e09018a5f Mon Sep 17 00:00:00 2001 From: Brayan Jules Date: Wed, 24 Jul 2024 20:48:17 -0400 Subject: [PATCH 1/2] bench: fix db lock on benchmark code by splitting the scopes between limbo and rusqlite. --- core/benches/benchmark.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/core/benches/benchmark.rs b/core/benches/benchmark.rs index 9be7679ec..dd56c3f37 100644 --- a/core/benches/benchmark.rs +++ b/core/benches/benchmark.rs @@ -4,9 +4,20 @@ use pprof::criterion::{Output, PProfProfiler}; use std::sync::Arc; fn bench(c: &mut Criterion) { - let mut group = c.benchmark_group("limbo"); - group.throughput(Throughput::Elements(1)); + limbo_bench(c); + // https://github.com/penberg/limbo/issues/174 + // The rusqlite benchmark crashes on Mac M1 when using the flamegraph features + if std::env::var("DISABLE_RUSQLITE_BENCHMARK").is_ok() { + return; + } + + rusqlite_bench(c) +} + +fn limbo_bench(criterion: &mut Criterion){ + let mut group = criterion.benchmark_group("limbo"); + group.throughput(Throughput::Elements(1)); let io = Arc::new(PlatformIO::new().unwrap()); let db = Database::open_file(io.clone(), "../testing/testing.db").unwrap(); let conn = db.connect(); @@ -88,16 +99,10 @@ fn bench(c: &mut Criterion) { }); }, ); +} - drop(group); - - // https://github.com/penberg/limbo/issues/174 - // The rusqlite benchmark crashes on Mac M1 when using the flamegraph features - if std::env::var("DISABLE_RUSQLITE_BENCHMARK").is_ok() { - return; - } - - let mut group = c.benchmark_group("rusqlite"); +fn rusqlite_bench(criterion: &mut Criterion){ + let mut group = criterion.benchmark_group("rusqlite"); group.throughput(Throughput::Elements(1)); let conn = rusqlite::Connection::open("../testing/testing.db").unwrap(); From 78568a53e39c304dafde822b10f6245e310009ac Mon Sep 17 00:00:00 2001 From: Brayan Jules Date: Wed, 24 Jul 2024 21:09:36 -0400 Subject: [PATCH 2/2] fix format issues --- core/benches/benchmark.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/benches/benchmark.rs b/core/benches/benchmark.rs index dd56c3f37..2dbe67962 100644 --- a/core/benches/benchmark.rs +++ b/core/benches/benchmark.rs @@ -15,7 +15,7 @@ fn bench(c: &mut Criterion) { rusqlite_bench(c) } -fn limbo_bench(criterion: &mut Criterion){ +fn limbo_bench(criterion: &mut Criterion) { let mut group = criterion.benchmark_group("limbo"); group.throughput(Throughput::Elements(1)); let io = Arc::new(PlatformIO::new().unwrap()); @@ -101,7 +101,7 @@ fn limbo_bench(criterion: &mut Criterion){ ); } -fn rusqlite_bench(criterion: &mut Criterion){ +fn rusqlite_bench(criterion: &mut Criterion) { let mut group = criterion.benchmark_group("rusqlite"); group.throughput(Throughput::Elements(1));