Skip to content

Commit 7564150

Browse files
committed
Add database persistence benchmarks
Benchmark realistic payment and pending-payment persistence workloads across filesystem, SQLite, and optional PostgreSQL stores. Use the async KV-store APIs so the measured paths match the database interfaces used by async persistence.
1 parent 84ae68f commit 7564150

4 files changed

Lines changed: 589 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ panic = 'abort' # Abort on panic
2525

2626
[features]
2727
default = []
28+
bench = ["dep:criterion"]
2829
postgres = ["dep:tokio-postgres", "dep:native-tls", "dep:postgres-native-tls"]
2930

3031
[dependencies]
@@ -77,6 +78,7 @@ uniffi = { version = "0.29.5", features = ["build"], optional = true }
7778
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
7879
serde_json = { version = "1.0.128", default-features = false, features = ["std"] }
7980
log = { version = "0.4.22", default-features = false, features = ["std"]}
81+
criterion = { version = "0.7.0", features = ["async_tokio"], optional = true }
8082

8183
async-trait = { version = "0.1", default-features = false }
8284
tokio-postgres = { version = "0.7", default-features = false, features = ["runtime"], optional = true }
@@ -140,6 +142,10 @@ check-cfg = [
140142
name = "payments"
141143
harness = false
142144

145+
[[bench]]
146+
name = "database"
147+
harness = false
148+
143149
#[patch.crates-io]
144150
#lightning = { path = "../rust-lightning/lightning" }
145151
#lightning-types = { path = "../rust-lightning/lightning-types" }

benches/database.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#[cfg(not(feature = "bench"))]
2+
compile_error!("run database benchmarks with `cargo bench --features bench --bench database`");
3+
4+
use criterion::{criterion_group, criterion_main, Criterion};
5+
6+
fn database_benchmark(c: &mut Criterion) {
7+
ldk_node::bench::database_benchmark(c);
8+
}
9+
10+
criterion_group!(benches, database_benchmark);
11+
criterion_main!(benches);

0 commit comments

Comments
 (0)