Skip to content

Commit f785ff1

Browse files
committed
Push the route benchmark results into a separate uninlined function
This ensures the route benchmarks themselves will appear with a distinct callgraph, making router profiling somewhat easier.
1 parent 89ce35e commit f785ff1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lightning/src/routing/router.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8758,14 +8758,23 @@ pub mod benches {
87588758
score_params: &S::ScoreParams, features: Bolt11InvoiceFeatures, starting_amount: u64,
87598759
bench_name: &'static str,
87608760
) {
8761-
let payer = bench_utils::payer_pubkey();
8762-
let keys_manager = KeysManager::new(&[0u8; 32], 42, 42);
8763-
let random_seed_bytes = keys_manager.get_secure_random_bytes();
8764-
87658761
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
87668762
let route_endpoints = bench_utils::generate_test_routes(graph, &mut scorer, score_params, features, 0xdeadbeef, starting_amount, 50);
87678763

87688764
// ...then benchmark finding paths between the nodes we learned.
8765+
do_route_bench(bench, graph, scorer, score_params, bench_name, route_endpoints);
8766+
}
8767+
8768+
#[inline(never)]
8769+
fn do_route_bench<S: ScoreLookUp + ScoreUpdate>(
8770+
bench: &mut Criterion, graph: &NetworkGraph<&TestLogger>, scorer: S,
8771+
score_params: &S::ScoreParams, bench_name: &'static str,
8772+
route_endpoints: Vec<(ChannelDetails, PaymentParameters, u64)>,
8773+
) {
8774+
let payer = bench_utils::payer_pubkey();
8775+
let keys_manager = KeysManager::new(&[0u8; 32], 42, 42);
8776+
let random_seed_bytes = keys_manager.get_secure_random_bytes();
8777+
87698778
let mut idx = 0;
87708779
bench.bench_function(bench_name, |b| b.iter(|| {
87718780
let (first_hop, params, amt) = &route_endpoints[idx % route_endpoints.len()];

0 commit comments

Comments
 (0)