Force inlining source and target node id lookup in candidate hops 2023-12-layout-graph-mem
authorMatt Corallo <git@bluematt.me>
Sat, 9 Dec 2023 21:12:30 +0000 (21:12 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 21 Dec 2023 16:36:04 +0000 (16:36 +0000)
Because our router is rather large, LLVM doesn't always decide to
inline small functions in it, opting instead for a call. This is
somewhat wasteful when we do repeated `match`es on the same data,
so here we force inlining of the `source` and `target` `NodeId`
lookups.

lightning/src/routing/router.rs

index 75bd47fb91b5798a1d580a4343b1059b1c764fb9..eb01e466b9dcc4299bc4e16897977b87670d498f 100644 (file)
@@ -1405,7 +1405,7 @@ impl<'a> CandidateRouteHop<'a> {
        /// Source node id refers to the node forwarding the HTLC through this hop.
        ///
        /// For [`Self::FirstHop`] we return payer's node id.
-       #[inline]
+       #[inline(always)]
        pub fn source(&self) -> NodeId {
                match self {
                        CandidateRouteHop::FirstHop(hop) => *hop.payer_node_id,
@@ -1424,7 +1424,7 @@ impl<'a> CandidateRouteHop<'a> {
        ///
        /// For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source,
        /// and such a return value would be somewhat nonsensical.
-       #[inline]
+       #[inline(always)]
        pub fn target(&self) -> Option<NodeId> {
                match self {
                        CandidateRouteHop::FirstHop(hop) => Some(hop.details.counterparty.node_id.into()),