Skip to content

Commit 060e870

Browse files
committed
askrene: mcf: trade granularity for performance
Speed in getroutes up by setting the granularity to 1000 Amount (sats) | speedup ----------------------- 100 | 1.00 1000 | 1.00 10000 | 1.06 100000 | 1.31 1000000 | 2.64 Worst runtime of getroutes Amount (sats) | before (ms) | after (ms) -------------------------------------- 100 | 1507 | 761 1000 | 2129 | 1214 10000 | 1632 | 1043 100000 | 2004 | 1150 1000000 | 27170 | 3289 Changelog-None Signed-off-by: Lagrang3 <[email protected]>
1 parent f717df6 commit 060e870

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

plugins/askrene/mcf.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,10 +969,15 @@ struct flow **minflow(const tal_t *ctx,
969969
params->source = source;
970970
params->target = target;
971971
params->amount = amount;
972-
params->accuracy = AMOUNT_MSAT(1000);
973-
/* FIXME: params->accuracy = amount_msat_max(amount_msat_div(amount,
974-
* 1000), AMOUNT_MSAT(1));
972+
/* -> We reduce the granularity of the flow by limiting the subdivision
973+
* of the payment amount into 1000 units of flow. That reduces the
974+
* computational burden for algorithms that depend on it, eg. "capacity
975+
* scaling" and "successive shortest path".
976+
* -> Using Ceil operation instead of Floor so that
977+
* accuracy x 1000 >= amount
975978
* */
979+
params->accuracy =
980+
amount_msat_max(AMOUNT_MSAT(1), amount_msat_div_ceil(amount, 1000));
976981

977982
// template the channel partition into linear arcs
978983
params->cap_fraction[0]=0;

tests/test_askrene.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,10 +1204,10 @@ def test_real_data(node_factory, bitcoind):
12041204
# CI, it's slow.
12051205
if SLOW_MACHINE:
12061206
limit = 25
1207-
expected = (5, 25, 1567535, 142772, 91)
1207+
expected = (6, 25, 1568821, 143649, 91)
12081208
else:
12091209
limit = 100
1210-
expected = (9, 96, 6563767, 629671, 91)
1210+
expected = (9, 96, 6565467, 630668, 91)
12111211

12121212
fees = {}
12131213
for n in range(0, limit):
@@ -1324,7 +1324,7 @@ def test_real_biases(node_factory, bitcoind):
13241324
expected = ({1: 6, 2: 6, 4: 7, 8: 12, 16: 14, 32: 19, 64: 25, 100: 25}, 0)
13251325
else:
13261326
limit = 100
1327-
expected = ({1: 22, 2: 25, 4: 36, 8: 52, 16: 69, 32: 80, 64: 96, 100: 96}, 0)
1327+
expected = ({1: 22, 2: 25, 4: 36, 8: 53, 16: 69, 32: 80, 64: 96, 100: 96}, 0)
13281328

13291329
l1.rpc.askrene_create_layer('biases')
13301330
num_changed = {}

0 commit comments

Comments
 (0)