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>
Thu, 6 Jun 2024 15:56:48 +0000 (15:56 +0000)
commit62ffd783175cda66ac416bc0410f47dfec07c31d
tree169a65c54f1d4557f47e78a485dd84faee4438af
parent3d9d38f1af8316fbfac7a1d66c1f7ad2c8455322
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