@@ -1150,12 +1150,7 @@ impl cmp::PartialOrd for RouteGraphNode {
1150
1150
1151
1151
// While RouteGraphNode can be laid out with fewer bytes, performance appears to be improved
1152
1152
// substantially when it is laid out at exactly 64 bytes.
1153
- //
1154
- // Thus, we use `#[repr(C)]` on the struct to force a suboptimal layout and check that it stays 64
1155
- // bytes here.
1156
- #[ cfg( any( ldk_bench, not( any( test, fuzzing) ) ) ) ]
1157
1153
const _GRAPH_NODE_SMALL: usize = 64 - core:: mem:: size_of :: < RouteGraphNode > ( ) ;
1158
- #[ cfg( any( ldk_bench, not( any( test, fuzzing) ) ) ) ]
1159
1154
const _GRAPH_NODE_FIXED_SIZE: usize = core:: mem:: size_of :: < RouteGraphNode > ( ) - 64 ;
1160
1155
1161
1156
/// A [`CandidateRouteHop::FirstHop`] entry.
@@ -1649,7 +1644,7 @@ fn iter_equal<I1: Iterator, I2: Iterator>(mut iter_a: I1, mut iter_b: I2)
1649
1644
/// Fee values should be updated only in the context of the whole path, see update_value_and_recompute_fees.
1650
1645
/// These fee values are useful to choose hops as we traverse the graph "payee-to-payer".
1651
1646
#[ derive( Clone ) ]
1652
- #[ repr( C ) ] // Force fields to appear in the order we define them.
1647
+ #[ repr( align ( 128 ) ) ]
1653
1648
struct PathBuildingHop < ' a > {
1654
1649
candidate : CandidateRouteHop < ' a > ,
1655
1650
target_node_counter : Option < u32 > ,
@@ -1679,11 +1674,6 @@ struct PathBuildingHop<'a> {
1679
1674
/// channel scoring.
1680
1675
path_penalty_msat : u64 ,
1681
1676
1682
- // The last 16 bytes are on the next cache line by default in glibc's malloc. Thus, we should
1683
- // only place fields which are not hot there. Luckily, the next three fields are only read if
1684
- // we end up on the selected path, and only in the final path layout phase, so we don't care
1685
- // too much if reading them is slow.
1686
-
1687
1677
fee_msat : u64 ,
1688
1678
1689
1679
/// All the fees paid *after* this channel on the way to the destination
@@ -1700,17 +1690,8 @@ struct PathBuildingHop<'a> {
1700
1690
value_contribution_msat : u64 ,
1701
1691
}
1702
1692
1703
- // Checks that the entries in the `find_route` `dist` map fit in (exactly) two standard x86-64
1704
- // cache lines. Sadly, they're not guaranteed to actually lie on a cache line (and in fact,
1705
- // generally won't, because at least glibc's malloc will align to a nice, big, round
1706
- // boundary...plus 16), but at least it will reduce the amount of data we'll need to load.
1707
- //
1708
- // Note that these assertions only pass on somewhat recent rustc, and thus are gated on the
1709
- // ldk_bench flag.
1710
- #[ cfg( ldk_bench) ]
1711
- const _NODE_MAP_SIZE_TWO_CACHE_LINES: usize = 128 - core:: mem:: size_of :: < ( NodeId , PathBuildingHop ) > ( ) ;
1712
- #[ cfg( ldk_bench) ]
1713
- const _NODE_MAP_SIZE_EXACTLY_CACHE_LINES: usize = core:: mem:: size_of :: < ( NodeId , PathBuildingHop ) > ( ) - 128 ;
1693
+ const _NODE_MAP_SIZE_TWO_CACHE_LINES: usize = 128 - core:: mem:: size_of :: < Option < PathBuildingHop > > ( ) ;
1694
+ const _NODE_MAP_SIZE_EXACTLY_TWO_CACHE_LINES: usize = core:: mem:: size_of :: < Option < PathBuildingHop > > ( ) - 128 ;
1714
1695
1715
1696
impl < ' a > core:: fmt:: Debug for PathBuildingHop < ' a > {
1716
1697
fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> Result < ( ) , core:: fmt:: Error > {
0 commit comments