@@ -1673,7 +1673,7 @@ fn iter_equal<I1: Iterator, I2: Iterator>(mut iter_a: I1, mut iter_b: I2)
1673
1673
/// Fee values should be updated only in the context of the whole path, see update_value_and_recompute_fees.
1674
1674
/// These fee values are useful to choose hops as we traverse the graph "payee-to-payer".
1675
1675
#[ derive( Clone ) ]
1676
- #[ repr( C ) ] // Force fields to appear in the order we define them.
1676
+ #[ repr( align ( 128 ) ) ] // Force the struct to align to cache line pairs
1677
1677
struct PathBuildingHop < ' a > {
1678
1678
candidate : CandidateRouteHop < ' a > ,
1679
1679
/// If we've already processed a node as the best node, we shouldn't process it again. Normally
@@ -1694,11 +1694,6 @@ struct PathBuildingHop<'a> {
1694
1694
/// channel scoring.
1695
1695
path_penalty_msat : u64 ,
1696
1696
1697
- // The last 16 bytes are on the next cache line by default in glibc's malloc. Thus, we should
1698
- // only place fields which are not hot there. Luckily, the next three fields are only read if
1699
- // we end up on the selected path, and only in the final path layout phase, so we don't care
1700
- // too much if reading them is slow.
1701
-
1702
1697
fee_msat : u64 ,
1703
1698
1704
1699
/// All the fees paid *after* this channel on the way to the destination
@@ -1716,16 +1711,9 @@ struct PathBuildingHop<'a> {
1716
1711
}
1717
1712
1718
1713
// Checks that the entries in the `find_route` `dist` map fit in (exactly) two standard x86-64
1719
- // cache lines. Sadly, they're not guaranteed to actually lie on a cache line (and in fact,
1720
- // generally won't, because at least glibc's malloc will align to a nice, big, round
1721
- // boundary...plus 16), but at least it will reduce the amount of data we'll need to load.
1722
- //
1723
- // Note that these assertions only pass on somewhat recent rustc, and thus are gated on the
1724
- // ldk_bench flag.
1725
- #[ cfg( ldk_bench) ]
1726
- const _NODE_MAP_SIZE_TWO_CACHE_LINES: usize = 128 - core:: mem:: size_of :: < ( NodeId , PathBuildingHop ) > ( ) ;
1727
- #[ cfg( ldk_bench) ]
1728
- const _NODE_MAP_SIZE_EXACTLY_CACHE_LINES: usize = core:: mem:: size_of :: < ( NodeId , PathBuildingHop ) > ( ) - 128 ;
1714
+ // cache lines.
1715
+ const _NODE_MAP_SIZE_TWO_CACHE_LINES: usize = 128 - core:: mem:: size_of :: < Option < PathBuildingHop > > ( ) ;
1716
+ const _NODE_MAP_SIZE_EXACTLY_CACHE_LINES: usize = core:: mem:: size_of :: < Option < PathBuildingHop > > ( ) - 128 ;
1729
1717
1730
1718
impl < ' a > core:: fmt:: Debug for PathBuildingHop < ' a > {
1731
1719
fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> Result < ( ) , core:: fmt:: Error > {
0 commit comments