-
Notifications
You must be signed in to change notification settings - Fork 42
Use growth factor 1.5x for read_buffer #502
Copy link
Copy link
Open
Description
Change the buffer growth strategy in read_buffer::grow_to_fit() from allocating exactly required_size to allocate std::max(required_size, buffer_.size() * 1.5) or required_size * 1.5, because:
- This could reduce amount of reallocations (imagine situation where reallocation happens just for few bytes).
- This could reduce heap fragmentation in case we use
std::max(required_size, buffer_.size() * 1.5), because we amortize future reallocations to match growth factor of 1.5.
But memory usage will be higher. In the worst case, the buffer capacity may grow to 1.5× the maximum message size, but that also mean we can avoid memmoves for such big messages if we use approach mentioned in #501
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels