Skip to content

Commit

Permalink
Stop checking ChannelLiquidity's in-memory size
Browse files Browse the repository at this point in the history
We generally expect `ChannelLiquidity` to be exactly three cache
lines to ensure the first bytes we need are all one one cache line.
This improves performance very marginally on some machines, but
the assertions that this is true do not work on some Android 32-bit
machines due to differing `Duration` sizes.

Here we simply remove the assertions to fix build on platforms
where the struct size isn't exactly on cache lines. This may
marginally harm performance but it shouldn't be that critical.

Fixes lightningdevkit#3415
  • Loading branch information
TheBlueMatt committed Feb 19, 2025
1 parent 940ca49 commit 2c2decf
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions lightning/src/routing/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,16 +821,6 @@ struct ChannelLiquidity {
offset_history_last_updated: Duration,
}

// Check that the liquidity HashMap's entries sit on round cache lines.
//
// Specifically, the first cache line will have the key, the liquidity offsets, and the total
// points tracked in the historical tracker.
//
// The next two cache lines will have the historical points, which we only access last during
// scoring, followed by the last_updated `Duration`s (which we do not need during scoring).
const _LIQUIDITY_MAP_SIZING_CHECK: usize = 192 - ::core::mem::size_of::<(u64, ChannelLiquidity)>();
const _LIQUIDITY_MAP_SIZING_CHECK_2: usize = ::core::mem::size_of::<(u64, ChannelLiquidity)>() - 192;

/// A snapshot of [`ChannelLiquidity`] in one direction assuming a certain channel capacity.
struct DirectedChannelLiquidity<L: Deref<Target = u64>, HT: Deref<Target = HistoricalLiquidityTracker>, T: Deref<Target = Duration>> {
min_liquidity_offset_msat: L,
Expand Down

0 comments on commit 2c2decf

Please sign in to comment.