gossipd: implement Dijkstra.

Use a uintmap as our minheap.

Note that Dijkstra can give overlength routes, so some checks are disabled.

Comparison using gossipd/test/run-bench-find_route 100000 10:

Before:
	10 (10 succeeded) routes in 100000 nodes in 120087 msec (12008708402 nanoseconds per route)
After:
	10 (10 succeeded) routes in 100000 nodes in 2269 msec (226925462 nanoseconds per route)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-04-17 17:05:33 +09:30
parent 4d84a436f5
commit 7caa37f0f1
4 changed files with 439 additions and 17 deletions

View File

@@ -118,6 +118,13 @@ struct node {
/* Where that came from. */
struct chan *prev;
} bfg[ROUTING_MAX_HOPS+1];
struct {
/* Total to get to here from target. */
struct amount_msat total;
/* Total risk premium of this route. */
struct amount_msat risk;
} dijkstra;
};
const struct node_id *node_map_keyof_node(const struct node *n);
@@ -428,4 +435,7 @@ static inline void local_enable_chan(struct routing_state *rstate,
/* Helper to convert on-wire addresses format to wireaddrs array */
struct wireaddr *read_addresses(const tal_t *ctx, const u8 *ser);
/* Temporary to set routing algo */
extern bool only_dijkstra;
#endif /* LIGHTNING_GOSSIPD_ROUTING_H */