Skip to content
Browse files

gossipd/routing: Iterate on Dijkstra when route is too long.

If a route is too long, we try to bias Dijkstra towards choosing a
shorter route by adding a per-hop cost.  We do a naive "shortest path"
pass, then using that cost as a ceiling on per-hop cost, we do a
binary search.

There are some subtleties: we use risk rather than total as our
counter field (we normally bias this by 1 anyway, so it's easy to make
that a variable), and we set riskfactor to a mimimal value once we're
iterating.  It's good enough to get a solution, we don't need to do a
2-dimensional search on riskfactor and riskbias.

Of course, this is extremely slow if we hit it on our benchmark,
though it doesn't happen in a more realistic network:

$ gossipd/test/run-bench-find_route 100000 100:

	100 (79 succeeded) routes in 100000 nodes in 25341 msec (253412314 nanoseconds per route)

	100 (100 succeeded) routes in 100000 nodes in 97346 msec (973461784 nanoseconds per route)

Signed-off-by: Rusty Russell <>
  • Loading branch information...
rustyrussell committed Apr 17, 2019
1 parent f8ffae8 commit e197956032ec68470644766f52f9e50470b66a1c
Showing with 246 additions and 68 deletions.
  1. +244 −60 gossipd/routing.c
  2. +2 −3 gossipd/test/run-bench-find_route.c
  3. +0 −5 gossipd/test/run-overlong.c
Oops, something went wrong.

0 comments on commit e197956

Please sign in to comment.
You can’t perform that action at this time.