@@ -1310,15 +1310,15 @@ fn iter_equal<I1: Iterator, I2: Iterator>(mut iter_a: I1, mut iter_b: I2)
1310
1310
/// Fee values should be updated only in the context of the whole path, see update_value_and_recompute_fees.
1311
1311
/// These fee values are useful to choose hops as we traverse the graph "payee-to-payer".
1312
1312
#[ derive( Clone ) ]
1313
+ #[ repr( C ) ] // Force fields to appear in the order we define them.
1313
1314
struct PathBuildingHop < ' a > {
1314
1315
candidate : CandidateRouteHop < ' a > ,
1315
- fee_msat : u64 ,
1316
-
1317
- /// All the fees paid *after* this channel on the way to the destination
1318
- next_hops_fee_msat : u64 ,
1319
- /// Fee paid for the use of the current channel (see candidate.fees()).
1320
- /// The value will be actually deducted from the counterparty balance on the previous link.
1321
- hop_use_fee_msat : u64 ,
1316
+ /// If we've already processed a node as the best node, we shouldn't process it again. Normally
1317
+ /// we'd just ignore it if we did as all channels would have a higher new fee, but because we
1318
+ /// may decrease the amounts in use as we walk the graph, the actual calculated fee may
1319
+ /// decrease as well. Thus, we have to explicitly track which nodes have been processed and
1320
+ /// avoid processing them again.
1321
+ was_processed : bool ,
1322
1322
/// Used to compare channels when choosing the for routing.
1323
1323
/// Includes paying for the use of a hop and the following hops, as well as
1324
1324
/// an estimated cost of reaching this hop.
@@ -1330,12 +1330,20 @@ struct PathBuildingHop<'a> {
1330
1330
/// All penalties incurred from this channel on the way to the destination, as calculated using
1331
1331
/// channel scoring.
1332
1332
path_penalty_msat : u64 ,
1333
- /// If we've already processed a node as the best node, we shouldn't process it again. Normally
1334
- /// we'd just ignore it if we did as all channels would have a higher new fee, but because we
1335
- /// may decrease the amounts in use as we walk the graph, the actual calculated fee may
1336
- /// decrease as well. Thus, we have to explicitly track which nodes have been processed and
1337
- /// avoid processing them again.
1338
- was_processed : bool ,
1333
+
1334
+ // The last 16 bytes are on the next cache line by default in glibc's malloc. Thus, we should
1335
+ // only place fields which are not hot there. Luckily, the next three fields are only read if
1336
+ // we end up on the selected path, and only in the final path layout phase, so we don't care
1337
+ // too much if reading them is slow.
1338
+
1339
+ fee_msat : u64 ,
1340
+
1341
+ /// All the fees paid *after* this channel on the way to the destination
1342
+ next_hops_fee_msat : u64 ,
1343
+ /// Fee paid for the use of the current channel (see candidate.fees()).
1344
+ /// The value will be actually deducted from the counterparty balance on the previous link.
1345
+ hop_use_fee_msat : u64 ,
1346
+
1339
1347
#[ cfg( all( not( ldk_bench) , any( test, fuzzing) ) ) ]
1340
1348
// In tests, we apply further sanity checks on cases where we skip nodes we already processed
1341
1349
// to ensure it is specifically in cases where the fee has gone down because of a decrease in
0 commit comments