]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Push the route benchmark results into a separate uninlined function
authorMatt Corallo <git@bluematt.me>
Sat, 9 Dec 2023 18:51:09 +0000 (18:51 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 12 Jun 2024 19:35:06 +0000 (19:35 +0000)
This ensures the route benchmarks themselves will appear with a
distinct callgraph, making router profiling somewhat easier.

lightning/src/routing/router.rs

index 8cf9034bcf6e42e30cf55263c9e441bcf753197a..207b0903e6183056824fcc97c1b116de3f1f3c4d 100644 (file)
@@ -8747,14 +8747,23 @@ pub mod benches {
                score_params: &S::ScoreParams, features: Bolt11InvoiceFeatures, starting_amount: u64,
                bench_name: &'static str,
        ) {
-               let payer = bench_utils::payer_pubkey();
-               let keys_manager = KeysManager::new(&[0u8; 32], 42, 42);
-               let random_seed_bytes = keys_manager.get_secure_random_bytes();
-
                // First, get 100 (source, destination) pairs for which route-getting actually succeeds...
                let route_endpoints = bench_utils::generate_test_routes(graph, &mut scorer, score_params, features, 0xdeadbeef, starting_amount, 50);
 
                // ...then benchmark finding paths between the nodes we learned.
+               do_route_bench(bench, graph, scorer, score_params, bench_name, route_endpoints);
+       }
+
+       #[inline(never)]
+       fn do_route_bench<S: ScoreLookUp + ScoreUpdate>(
+               bench: &mut Criterion, graph: &NetworkGraph<&TestLogger>, scorer: S,
+               score_params: &S::ScoreParams, bench_name: &'static str,
+               route_endpoints: Vec<(ChannelDetails, PaymentParameters, u64)>,
+       ) {
+               let payer = bench_utils::payer_pubkey();
+               let keys_manager = KeysManager::new(&[0u8; 32], 42, 42);
+               let random_seed_bytes = keys_manager.get_secure_random_bytes();
+
                let mut idx = 0;
                bench.bench_function(bench_name, |b| b.iter(|| {
                        let (first_hop, params, amt) = &route_endpoints[idx % route_endpoints.len()];