@@ -1126,12 +1126,7 @@ impl cmp::PartialOrd for RouteGraphNode {
1126
1126
1127
1127
// While RouteGraphNode can be laid out with fewer bytes, performance appears to be improved
1128
1128
// substantially when it is laid out at exactly 64 bytes.
1129
- //
1130
- // Thus, we use `#[repr(C)]` on the struct to force a suboptimal layout and check that it stays 64
1131
- // bytes here.
1132
- #[ cfg( any( ldk_bench, not( any( test, fuzzing) ) ) ) ]
1133
1129
const _GRAPH_NODE_SMALL: usize = 64 - core:: mem:: size_of :: < RouteGraphNode > ( ) ;
1134
- #[ cfg( any( ldk_bench, not( any( test, fuzzing) ) ) ) ]
1135
1130
const _GRAPH_NODE_FIXED_SIZE: usize = core:: mem:: size_of :: < RouteGraphNode > ( ) - 64 ;
1136
1131
1137
1132
/// A [`CandidateRouteHop::FirstHop`] entry.
@@ -1532,7 +1527,7 @@ fn iter_equal<I1: Iterator, I2: Iterator>(mut iter_a: I1, mut iter_b: I2)
1532
1527
/// Fee values should be updated only in the context of the whole path, see update_value_and_recompute_fees.
1533
1528
/// These fee values are useful to choose hops as we traverse the graph "payee-to-payer".
1534
1529
#[ derive( Clone ) ]
1535
- #[ repr( C ) ] // Force fields to appear in the order we define them.
1530
+ #[ repr( align ( 128 ) ) ]
1536
1531
struct PathBuildingHop < ' a > {
1537
1532
candidate : CandidateRouteHop < ' a > ,
1538
1533
target_node_counter : Option < u32 > ,
@@ -1562,11 +1557,6 @@ struct PathBuildingHop<'a> {
1562
1557
/// channel scoring.
1563
1558
path_penalty_msat : u64 ,
1564
1559
1565
- // The last 16 bytes are on the next cache line by default in glibc's malloc. Thus, we should
1566
- // only place fields which are not hot there. Luckily, the next three fields are only read if
1567
- // we end up on the selected path, and only in the final path layout phase, so we don't care
1568
- // too much if reading them is slow.
1569
-
1570
1560
fee_msat : u64 ,
1571
1561
1572
1562
/// All the fees paid *after* this channel on the way to the destination
@@ -1583,17 +1573,8 @@ struct PathBuildingHop<'a> {
1583
1573
value_contribution_msat : u64 ,
1584
1574
}
1585
1575
1586
- // Checks that the entries in the `find_route` `dist` map fit in (exactly) two standard x86-64
1587
- // cache lines. Sadly, they're not guaranteed to actually lie on a cache line (and in fact,
1588
- // generally won't, because at least glibc's malloc will align to a nice, big, round
1589
- // boundary...plus 16), but at least it will reduce the amount of data we'll need to load.
1590
- //
1591
- // Note that these assertions only pass on somewhat recent rustc, and thus are gated on the
1592
- // ldk_bench flag.
1593
- #[ cfg( ldk_bench) ]
1594
- const _NODE_MAP_SIZE_TWO_CACHE_LINES: usize = 128 - core:: mem:: size_of :: < ( NodeId , PathBuildingHop ) > ( ) ;
1595
- #[ cfg( ldk_bench) ]
1596
- const _NODE_MAP_SIZE_EXACTLY_CACHE_LINES: usize = core:: mem:: size_of :: < ( NodeId , PathBuildingHop ) > ( ) - 128 ;
1576
+ const _NODE_MAP_SIZE_TWO_CACHE_LINES: usize = 128 - core:: mem:: size_of :: < Option < PathBuildingHop > > ( ) ;
1577
+ const _NODE_MAP_SIZE_EXACTLY_TWO_CACHE_LINES: usize = core:: mem:: size_of :: < Option < PathBuildingHop > > ( ) - 128 ;
1597
1578
1598
1579
impl < ' a > core:: fmt:: Debug for PathBuildingHop < ' a > {
1599
1580
fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> Result < ( ) , core:: fmt:: Error > {
0 commit comments