Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ url = "2.5.4"
[dev-dependencies]
alloy-hardforks = "0.4.0"
alloy-chains = "0.2"
criterion = { version = "0.8.2", features = ["async_tokio"] }
signet-bundle = "0.16.0-rc.11"

[[bench]]
name = "sim"
path = "benches/sim/main.rs"
harness = false

# comment / uncomment for local dev
# [patch.crates-io]
# signet-constants = { path = "../signet-sdk/crates/constants" }
Expand Down
111 changes: 111 additions & 0 deletions benches/sim/bundles.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
//! Benchmarks for bundle simulation: varying counts, DB latency, and concurrency.

use crate::fixture::{Fixture, LATENCIES, set_up_bundle_sim, set_up_sender_distribution_sim};
use builder::test_utils::setup_test_config;
use criterion::{BatchSize, Bencher, BenchmarkId, Criterion};
use std::time::Duration;

pub fn bench_bundle_counts(criterion: &mut Criterion) {
const LATENCY: Duration = Duration::ZERO;
const CONCURRENCY: usize = 4;

setup_test_config();
let runtime = tokio::runtime::Runtime::new().unwrap();

let mut group = criterion.benchmark_group("sim_varying_simple_bundle_counts_no_db_latency");
group.sample_size(10);

for bundle_count in [1, 10, 100, 1000] {
group.bench_with_input(
BenchmarkId::new("bundle_count", bundle_count),
&bundle_count,
|bench: &mut Bencher, &bundle_count| {
bench.to_async(&runtime).iter_batched(
|| set_up_bundle_sim(bundle_count, LATENCY, CONCURRENCY),
Fixture::run,
BatchSize::PerIteration,
);
},
);
}
group.finish();
}

pub fn bench_bundle_db_latency(criterion: &mut Criterion) {
const BUNDLE_COUNT: usize = 10;
const CONCURRENCY: usize = 4;

setup_test_config();
let runtime = tokio::runtime::Runtime::new().unwrap();

let mut group =
criterion.benchmark_group(format!("sim_{BUNDLE_COUNT}_simple_bundles_varying_db_latency"));
group.sample_size(10);

for (label, latency) in LATENCIES {
group.bench_with_input(BenchmarkId::new("latency", label), &latency, |bench, &lat| {
bench.to_async(&runtime).iter_batched(
|| set_up_bundle_sim(BUNDLE_COUNT, lat, CONCURRENCY),
Fixture::run,
BatchSize::PerIteration,
);
});
}
group.finish();
}

pub fn bench_bundle_concurrency(criterion: &mut Criterion) {
const BUNDLE_COUNT: usize = 100;
const LATENCY: Duration = Duration::ZERO;

setup_test_config();
let runtime = tokio::runtime::Runtime::new().unwrap();

let mut group = criterion.benchmark_group(format!(
"sim_{BUNDLE_COUNT}_simple_bundles_no_db_latency_varying_concurrency"
));
group.sample_size(10);

for concurrency in [1, 2, 4, 8, 16] {
group.bench_with_input(
BenchmarkId::new("thread_count", concurrency),
&concurrency,
|bench, &conc| {
bench.to_async(&runtime).iter_batched(
|| set_up_bundle_sim(BUNDLE_COUNT, LATENCY, conc),
Fixture::run,
BatchSize::PerIteration,
);
},
);
}
group.finish();
}

pub fn bench_bundle_sender_distribution(criterion: &mut Criterion) {
const BUNDLE_COUNT: usize = 100;
const CONCURRENCY: usize = 4;

setup_test_config();
let runtime = tokio::runtime::Runtime::new().unwrap();

let mut group = criterion.benchmark_group(format!(
"sim_{BUNDLE_COUNT}_simple_bundles_no_db_latency_varying_sender_count"
));
group.sample_size(10);

for num_senders in [1, 5, 20, 100] {
group.bench_with_input(
BenchmarkId::new("sender_count", num_senders),
&num_senders,
|bench, &senders| {
bench.to_async(&runtime).iter_batched(
|| set_up_sender_distribution_sim(BUNDLE_COUNT, senders, CONCURRENCY),
Fixture::run,
BatchSize::PerIteration,
);
},
);
}
group.finish();
}
61 changes: 61 additions & 0 deletions benches/sim/complex_bundles.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//! Benchmarks for complex bundle shapes: multi-tx bundles and bundles with host transactions.

use crate::fixture::{Fixture, set_up_host_tx_bundle_sim, set_up_multi_tx_bundle_sim};
use builder::test_utils::setup_test_config;
use criterion::{BatchSize, BenchmarkId, Criterion};

pub fn bench_multi_tx_bundles(criterion: &mut Criterion) {
const BUNDLE_COUNT: usize = 100;
const CONCURRENCY: usize = 4;

setup_test_config();
let runtime = tokio::runtime::Runtime::new().unwrap();

let mut group = criterion.benchmark_group(format!(
"sim_{BUNDLE_COUNT}_bundles_no_db_latency_varying_txs_per_bundle"
));
group.sample_size(10);

for txs_per_bundle in [1, 3, 5, 10] {
group.bench_with_input(
BenchmarkId::new("txs_per_bundle", txs_per_bundle),
&txs_per_bundle,
|bench, &tpb| {
bench.to_async(&runtime).iter_batched(
|| set_up_multi_tx_bundle_sim(BUNDLE_COUNT, tpb, CONCURRENCY),
Fixture::run,
BatchSize::PerIteration,
);
},
);
}
group.finish();
}

pub fn bench_host_tx_bundles(criterion: &mut Criterion) {
const BUNDLE_COUNT: usize = 100;
const CONCURRENCY: usize = 4;

setup_test_config();
let runtime = tokio::runtime::Runtime::new().unwrap();

let mut group = criterion.benchmark_group(format!(
"sim_{BUNDLE_COUNT}_bundles_no_db_latency_varying_host_txs_per_bundle"
));
group.sample_size(10);

for host_txs in [0, 1, 3, 5] {
group.bench_with_input(
BenchmarkId::new("host_txs_per_bundle", host_txs),
&host_txs,
|bench, &htpb| {
bench.to_async(&runtime).iter_batched(
|| set_up_host_tx_bundle_sim(BUNDLE_COUNT, htpb, CONCURRENCY),
Fixture::run,
BatchSize::PerIteration,
);
},
);
}
group.finish();
}
Loading