Layout channel info to ensure routing uses cache lines well 2023-12-routing-dist-vec
authorMatt Corallo <git@bluematt.me>
Sat, 9 Dec 2023 21:22:52 +0000 (21:22 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 20 Mar 2024 00:51:20 +0000 (00:51 +0000)
commitf53cc4c4bfc4a39bb3911a6206906b6f77f7d340
treea60bc862f7196bc01beff32de893cb199867dba1
parent9df8d441ea127f32bd26d74e1a72d9e687849cd5
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