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;
|
||||
}
|
||||
|
||||
// Update the size hint, ensuring it slowly shrinks over time to
|
||||
// prevent buffer runaway due to the occasional large buffer.
|
||||
size_hint = Some(b.ops.len().saturating_sub(1));
|
||||
// Update the size hint to match the size of the last batch.
|
||||
size_hint = Some(b.ops.len());
|
||||
|
||||
// Move the pre-allocated buffer to replace the old.
|
||||
std::mem::replace(&mut *b, new_buf)
|
||||
|
|
Loading…
Reference in New Issue