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
Dom Dwyer 2023-03-02 11:40:38 +01:00
parent a55bbebbee
commit f3caf604b5
No known key found for this signature in database
GPG Key ID: E4C40DBD9157879A
1 changed files with 2 additions and 3 deletions

View File

@ -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)