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
Change the buffer growth strategy in
read_buffer::grow_to_fit()from allocating exactlyrequired_sizeto allocatestd::max(required_size, buffer_.size() * 1.5)orrequired_size * 1.5, because: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