Skip to content

Commit 2c78de0

Browse files
committed
f comment more details why
1 parent a4f19f6 commit 2c78de0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lightning/src/routing/scoring.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,14 @@ mod bucketed_history {
16581658
#[derive(Clone, Copy)]
16591659
#[repr(C)] // Force the fields in memory to be in the order we specify.
16601660
pub(super) struct HistoricalLiquidityTracker {
1661+
// This struct sites inside a `(u64, ChannelLiquidity)` in memory, and we first read the
1662+
// liquidity offsets in `ChannelLiquidity` when calculating the non-historical score. This
1663+
// means that the first handful of bytes of this struct will already be sitting in cache by
1664+
// the time we go to look at them.
1665+
//
1666+
// Because the first thing we do is check if `total_valid_points` is sufficient to consider
1667+
// the data here at all, and can return early if it is not, we want this to go first to
1668+
// avoid hitting a second cache line load entirely in that case.
16611669
total_valid_points_tracked: u64,
16621670
min_liquidity_offset_history: HistoricalBucketRangeTracker,
16631671
max_liquidity_offset_history: HistoricalBucketRangeTracker,

0 commit comments

Comments
 (0)