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>
Thu, 21 Dec 2023 06:00:10 +0000 (06:00 +0000)
commit4d5c9141e2e09e1ab1488ac7368deb62aacb4be4
tree0007a016405bbe92d4254ff22623c02656ba7e54
parentb2cf4df798994b00f0899757fd830e954d4dd500
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