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