From 70226f731c0ab67e974d3764ae7a8d22ecd4cb51 Mon Sep 17 00:00:00 2001 From: Arya Rathore Date: Fri, 13 Nov 2026 11:29:39 +0530 Subject: [PATCH] plugin-askrene: cap dial iterations to avoid redundant solver runs The retry loop around the solver in linear_routes() repeatedly doubles the odds mu / (1 - mu) when the route fee exceeds maxfee. Previously, the cut-off was set to `near_one = 1. - 1e-6`, requiring 27 retries (28 solver runs) before failing. As reported in #9726: "The 17 added runs are at mu above 0.95, where a run is slower and the fee found changes little or rises... Effect on a mainnet node that rebalances with a tight fee budget, v26.06.10 against v26.06.9: the median rebalance request takes 26 s against 5 s, and 12.8% of them end in the timeout (askrene-timeout 30); none did before." Introduce `max_mu = 0.99` to cap mu iterations while keeping `near_one = 1. - 1e-6` for delay/hop dials and the flow_fee_adjustment fallback. This bounds the maximum number of solver attempts to 15, avoiding the diminishing-returns iterations above mu=0.95 where fee priority is already ~99% and MCF solver passes become significantly more expensive without improving found fees. Fixes #9726 Changelog-Fixed: askrene: bound dial iterations to avoid redundant solver runs when fee exceeds budget. --- plugins/askrene/child/mcf.c | 6 +++++- tests/test_askrene.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/askrene/child/mcf.c b/plugins/askrene/child/mcf.c index 3842c9492b6e..7d03c5b1e0c7 100644 --- a/plugins/askrene/child/mcf.c +++ b/plugins/askrene/child/mcf.c @@ -1507,6 +1507,10 @@ linear_routes(const tal_t *ctx, struct route_query *rq, { /* Almost 1 to limit the dials' iterations. */ const double near_one = 1. - 1e-6; + /* A cut-off at 0.99 avoids excessive iterations in the + * diminishing-returns range above 0.95 where solver runs become + * slower and fee improvements stagnate or degrade (issue #9726). */ + const double max_mu = 0.99; const tal_t *working_ctx = tal(ctx, tal_t); const char *error_message; struct amount_msat amount_to_deliver = amount; @@ -1710,7 +1714,7 @@ linear_routes(const tal_t *ctx, struct route_query *rq, goto fail; } if (amount_msat_greater(all_fees, partial_feebudget)) { - if (mu < near_one) { + if (mu < max_mu) { /* all_fees exceed the strong budget limit, try * to fix it increasing mu. */ mu *= 2; diff --git a/tests/test_askrene.py b/tests/test_askrene.py index fc8515256e2c..2e77f24d9745 100644 --- a/tests/test_askrene.py +++ b/tests/test_askrene.py @@ -2314,6 +2314,11 @@ def test_excessive_fee_cost(node_factory): maxparts=1, ) + # Dial iterations cut off once mu >= 0.99, bounding solver runs (issue #9726) + l1.daemon.logs_catchup() + mu_retries = [l for l in l1.daemon.logs if "retrying with mu of" in l] + assert 0 < len(mu_retries) <= 15 + def check_getroute_routes( node,