Skip to content

Commit 38634c2

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 38634c2

5 files changed

Lines changed: 588 additions & 1 deletion

File tree

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
echo "ELECTRS_EXE=$( pwd )/bin/electrs-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
4444
- name: Run benchmarks
4545
run: |
46-
cargo bench
46+
cargo bench --features bench

Cargo.toml

Lines changed: 7 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,11 @@ check-cfg = [
140142
name = "payments"
141143
harness = false
142144

145+
[[bench]]
146+
name = "database"
147+
harness = false
148+
required-features = ["bench"]
149+
143150
#[patch.crates-io]
144151
#lightning = { path = "../rust-lightning/lightning" }
145152
#lightning-types = { path = "../rust-lightning/lightning-types" }

benches/database.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use criterion::{criterion_group, criterion_main, Criterion};
2+
3+
fn database_benchmark(c: &mut Criterion) {
4+
ldk_node::bench::database_benchmark(c);
5+
}
6+
7+
criterion_group!(benches, database_benchmark);
8+
criterion_main!(benches);

0 commit comments

Comments
 (0)