Skip to content

Add an option to make the success probability estimation nonlinear #2547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
3 changes: 3 additions & 0 deletions bench/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ criterion_group!(benches,
lightning::routing::router::benches::generate_routes_with_probabilistic_scorer,
lightning::routing::router::benches::generate_mpp_routes_with_probabilistic_scorer,
lightning::routing::router::benches::generate_large_mpp_routes_with_probabilistic_scorer,
lightning::routing::router::benches::generate_routes_with_nonlinear_probabilistic_scorer,
lightning::routing::router::benches::generate_mpp_routes_with_nonlinear_probabilistic_scorer,
lightning::routing::router::benches::generate_large_mpp_routes_with_nonlinear_probabilistic_scorer,
lightning::sign::benches::bench_get_secure_random_bytes,
lightning::ln::channelmanager::bench::bench_sends,
lightning_persister::fs_store::bench::bench_sends,
Expand Down
41 changes: 39 additions & 2 deletions lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2315,8 +2315,9 @@ where L::Target: Logger {
// Decrease the available liquidity of a hop in the middle of the path.
let victim_candidate = &payment_path.hops[(payment_path.hops.len()) / 2].0.candidate;
let exhausted = u64::max_value();
log_trace!(logger, "Disabling route candidate {} for future path building iterations to
avoid duplicates.", LoggedCandidateHop(victim_candidate));
log_trace!(logger,
"Disabling route candidate {} for future path building iterations to avoid duplicates.",
LoggedCandidateHop(victim_candidate));
*used_liquidities.entry(victim_candidate.id(false)).or_default() = exhausted;
*used_liquidities.entry(victim_candidate.id(true)).or_default() = exhausted;
}
Expand Down Expand Up @@ -7324,6 +7325,42 @@ pub mod benches {
"generate_large_mpp_routes_with_probabilistic_scorer");
}

pub fn generate_routes_with_nonlinear_probabilistic_scorer(bench: &mut Criterion) {
let logger = TestLogger::new();
let network_graph = bench_utils::read_network_graph(&logger).unwrap();
let mut params = ProbabilisticScoringFeeParameters::default();
params.linear_success_probability = false;
let scorer = ProbabilisticScorer::new(
ProbabilisticScoringDecayParameters::default(), &network_graph, &logger);
generate_routes(bench, &network_graph, scorer, &params,
channelmanager::provided_invoice_features(&UserConfig::default()), 0,
"generate_routes_with_nonlinear_probabilistic_scorer");
}

pub fn generate_mpp_routes_with_nonlinear_probabilistic_scorer(bench: &mut Criterion) {
let logger = TestLogger::new();
let network_graph = bench_utils::read_network_graph(&logger).unwrap();
let mut params = ProbabilisticScoringFeeParameters::default();
params.linear_success_probability = false;
let scorer = ProbabilisticScorer::new(
ProbabilisticScoringDecayParameters::default(), &network_graph, &logger);
generate_routes(bench, &network_graph, scorer, &params,
channelmanager::provided_invoice_features(&UserConfig::default()), 0,
"generate_mpp_routes_with_nonlinear_probabilistic_scorer");
}

pub fn generate_large_mpp_routes_with_nonlinear_probabilistic_scorer(bench: &mut Criterion) {
let logger = TestLogger::new();
let network_graph = bench_utils::read_network_graph(&logger).unwrap();
let mut params = ProbabilisticScoringFeeParameters::default();
params.linear_success_probability = false;
let scorer = ProbabilisticScorer::new(
ProbabilisticScoringDecayParameters::default(), &network_graph, &logger);
generate_routes(bench, &network_graph, scorer, &params,
channelmanager::provided_invoice_features(&UserConfig::default()), 100_000_000,
"generate_large_mpp_routes_with_nonlinear_probabilistic_scorer");
}

fn generate_routes<S: ScoreLookUp + ScoreUpdate>(
bench: &mut Criterion, graph: &NetworkGraph<&TestLogger>, mut scorer: S,
score_params: &S::ScoreParams, features: Bolt11InvoiceFeatures, starting_amount: u64,
Expand Down
Loading