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 <noreply@anthropic.com>
This commit is contained in:
1 parent
cbc1dc7e44
commit
f1aca37ebe
1 file changed
+5
@@ -873,6 +873,11 @@ fn push_tight<T>(vec: &mut Vec<T>, 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)
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user