Repository navigation
askrene: skip redundant small-channel layer for single-path routing - #9750
decodekush wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
0801e06 to
99003a2
Compare
Andezion
left a comment
There was a problem hiding this comment.
Impressions can raise the limit above capacity. In layer_apply_constraints() (look at layer.c at line 1169to 1173), an impression in the opposite direction increases max. That path is used when capacities[idx] == 0 (channels with layer intel or reservations). So maxcap can exceed the channel s real capacity. The old layer disabled the channel based on raw capacity no matter what, and now the solver may pick it
also later rounds use a smaller amount. In linear_routes() (at file mcf.c at line 1567), if refine_flows() trims the first path, the next round calls single_path_flow() with a smaller amount_to_deliver. small channels the layer used to block can now be chosen. reduce_num_flows() still enforces one part, so i expect the same outcome, but possibly a different error message?
99003a2 to
bb5d6a5
Compare
When maxparts == 1, do_getroutes() previously built and applied the temporary layer auto.remove_small_channels, adding disabling updates for every channel whose capacity was below the payment amount. On a typical network graph with tens of thousands of channels, applying this layer triggered an O(N^2) scan in gossmap_local_updatechan() via find_localmod(), blocking askrene's main event loop for seconds to tens of seconds before the search even began. The single-path Dijkstra solver (init_linear_network_single_path) already excludes channels with insufficient capacity during graph initialization. The small-channel layer was an artifact of the original MCF solver (ElementsProject#8059) before the single-path solver existed (ElementsProject#8299). Remove remove_small_channel_layer and avoid constructing this layer. Also: - Explicitly check gossmap_chan_get_capacity in init_linear_network_single_path to skip insufficient capacity channels in O(1) time. - In route_query:get_constraints(), cap max liquidity at the channel's on-chain capacity to ensure reverse impressions cannot inflate the bound past physical capacity. - In test_getroutes_single_path, verify deterministic capacity shortfall reporting and test that reverse impressions cannot bypass capacity bounds. - In test_single_part_setup_time, mark as slow_test, drop unused bitcoind fixture and secondary node, narrow broken_log, and benchmark relative to default getroutes setup and search duration. Fixes: ElementsProject#9739 Changelog-Fixed: askrene: eliminate quadratic setup lag on single-path getroutes calls Signed-off-by: decodekush <kushagraagarwal1612@gmail.com>
bb5d6a5 to
4edaad5
Compare
|
Thanks for the review @Andezion. I've addressed all the feedback and pushed an updated commit with the following changes:
Also rebased cleanly onto latest master. All unit and integration tests are passing. |
Problem
As reported in #9739 by @ksedgwic, calling
getrouteswithmaxparts=1freezes the askrene plugin before the route search even begins.When$O(N^2)$ scan of ~40,000 updates that stalls the main plugin process synchronously for up to 42 seconds before forking the child router.
maxparts == 1,do_getroutes()builds the temporary layerauto.remove_small_channelsto disable every channel smaller than the requested amount. Applying this layer callsfind_localmod(), which does a linear scan from the start oflocalmods->modsfor each update. On mainnet gossip (~50,000 channels), this triggers anSolution
Skip constructing the small-channel layer for single-path routing.
remove_small_channel_layer()was originally added in #8059 as a workaround to force the old MCF solver to find single paths. The dedicated single-path Dijkstra solver added in #8299 (init_linear_network_single_path()) already checks channel capacities inRemoving this layer drops setup time on real gossip data from 13.9s to 0.017s for 2,000,000 sat calls. It also resolves the longstanding
# FIXME: the explanation for the failure is wrongintest_getroutes_single_path, accurately reporting that a channel isn't big enough rather than claiming it was disabled by an internal layer.Fixes #9739
Checklist
Changelog-Fixed:).tools/lightning-downgrade(N/A, in-memory layer).