refactor(wal): last batch length for preallocation
There's no need to sub 1 from the batch length to shrink the buffer over time - the capacity of the new batch will be the length of the last. A large batch followed by a small batch will cause the pre-allocated next batch to be small too.pull/24376/head
parent
a55bbebbee
commit
f3caf604b5
|
@ -362,9 +362,8 @@ impl Wal {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the size hint, ensuring it slowly shrinks over time to
|
// Update the size hint to match the size of the last batch.
|
||||||
// prevent buffer runaway due to the occasional large buffer.
|
size_hint = Some(b.ops.len());
|
||||||
size_hint = Some(b.ops.len().saturating_sub(1));
|
|
||||||
|
|
||||||
// Move the pre-allocated buffer to replace the old.
|
// Move the pre-allocated buffer to replace the old.
|
||||||
std::mem::replace(&mut *b, new_buf)
|
std::mem::replace(&mut *b, new_buf)
|
||||||
|
|
Loading…
Reference in New Issue