Layout channel info to ensure routing uses cache lines well
authorMatt Corallo <git@bluematt.me>
Sat, 9 Dec 2023 21:22:52 +0000 (21:22 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 10 Dec 2023 04:13:10 +0000 (04:13 +0000)
commitd60f72a58dd3beeb1b8363bd41b3db629aca65d0
treec76418998d317266d89cf13b26ea9b7635b7776d
parent31cbe17ff9d2be628495bb3806dfc4c3de028347
Layout channel info to ensure routing uses cache lines well

Because we scan per-channel information in the hot inner loop of
our routefinding immediately after looking a channel up in a
`HashMap`, we end up spending a nontrivial portion of our
routefinding time waiting on memory to be read in.

While there is only so much we can do about that, ensuring the
channel information that we care about is sitting on one or
adjacent cache lines avoids paying that penalty twice. Thus, here
we manually lay out `ChannelInfo` and `ChannelUpdateInfo` and set
them to 128b and 32b alignment, respectively. This wastes some
space in memory in our network graph, but improves routing
performance in return.
lightning/src/routing/gossip.rs