Skip to content

Commit d74c143

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 050e7eb commit d74c143

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
@@ -8747,14 +8747,23 @@ pub mod benches {
87478747
score_params: &S::ScoreParams, features: Bolt11InvoiceFeatures, starting_amount: u64,
87488748
bench_name: &'static str,
87498749
) {
8750-
let payer = bench_utils::payer_pubkey();
8751-
let keys_manager = KeysManager::new(&[0u8; 32], 42, 42);
8752-
let random_seed_bytes = keys_manager.get_secure_random_bytes();
8753-
87548750
// First, get 100 (source, destination) pairs for which route-getting actually succeeds...
87558751
let route_endpoints = bench_utils::generate_test_routes(graph, &mut scorer, score_params, features, 0xdeadbeef, starting_amount, 50);
87568752

87578753
// ...then benchmark finding paths between the nodes we learned.
8754+
do_route_bench(bench, graph, scorer, score_params, bench_name, route_endpoints);
8755+
}
8756+
8757+
#[inline(never)]
8758+
fn do_route_bench<S: ScoreLookUp + ScoreUpdate>(
8759+
bench: &mut Criterion, graph: &NetworkGraph<&TestLogger>, scorer: S,
8760+
score_params: &S::ScoreParams, bench_name: &'static str,
8761+
route_endpoints: Vec<(ChannelDetails, PaymentParameters, u64)>,
8762+
) {
8763+
let payer = bench_utils::payer_pubkey();
8764+
let keys_manager = KeysManager::new(&[0u8; 32], 42, 42);
8765+
let random_seed_bytes = keys_manager.get_secure_random_bytes();
8766+
87588767
let mut idx = 0;
87598768
bench.bench_function(bench_name, |b| b.iter(|| {
87608769
let (first_hop, params, amt) = &route_endpoints[idx % route_endpoints.len()];

0 commit comments

Comments
 (0)