From f1aca37ebefeaf25a8f12bcf896dd6c728e6dfd9 Mon Sep 17 00:00:00 2001 From: Rayhaan Jaufeerally Date: Sat, 10 Oct 2026 13:45:15 +0200 Subject: [PATCH] rib: a short row grows by doubling A prefix's row of paths is given room for as many paths as there are peers, and from there grows by a quarter at a time, one path at a time while it is short. A peer sending every path it has (ADD-PATH) gives a prefix several paths from one peer, so a row goes past the peers' count from the first few routes and was then reallocated for each path. A row shorter than the first allocation's room doubles instead, and grows by a quarter only from there. Measured on the mesh benchmark, the reallocations in the table's insert path fall by half; the memory held is as before, as the rows that reach the quarter-growth are the ones that were already allocated for it. Co-Authored-By: Claude Fable 5.1 --- crates/rib/src/table/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/rib/src/table/mod.rs b/crates/rib/src/table/mod.rs index 4fc5ad6..a4cd95e 100644 --- a/crates/rib/src/table/mod.rs +++ b/crates/rib/src/table/mod.rs @@ -873,6 +873,11 @@ fn push_tight(vec: &mut Vec, value: T, expected: usize) { let first = expected.min(FIRST_ROOM); let more = if vec.capacity() < first { first - vec.len() + } else if vec.capacity() < FIRST_ROOM { + // A peer that sends several routes for a prefix (ADD-PATH) + // takes a row past the peers' count: doubled while small, + // and from there by a quarter. + vec.capacity() } else { (vec.len() / 4).max(1) };