Skip to content

Commit

Permalink
Reduce malloc churn for console calls <=128KiB (#18287)
Browse files Browse the repository at this point in the history
This increases the console IO buffer size to retain at least 128KiB as
this matches the default buffer size of `cat`. This avoids allocator
churn due to constantly freeing and reallocating buffers. In the future
this should ideally use a better suited, cheap allocator.

Closes #18286
  • Loading branch information
lhecker authored Dec 5, 2024
1 parent ca8c3bb commit aa5459d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server/ApiMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ try

// If we were previously called with a huge buffer we have an equally large _inputBuffer.
// We shouldn't just keep this huge buffer around, if no one needs it anymore.
if (_inputBuffer.capacity() > 16 * 1024 && (_inputBuffer.capacity() >> 1) > cbReadSize)
if (_inputBuffer.capacity() > 128 * 1024 && (_inputBuffer.capacity() >> 1) > cbReadSize)
{
_inputBuffer.shrink_to_fit();
}
Expand Down Expand Up @@ -151,7 +151,7 @@ try

// If we were previously called with a huge buffer we have an equally large _outputBuffer.
// We shouldn't just keep this huge buffer around, if no one needs it anymore.
if (_outputBuffer.capacity() > 16 * 1024 && (_outputBuffer.capacity() >> 1) > cbWriteSize)
if (_outputBuffer.capacity() > 128 * 1024 && (_outputBuffer.capacity() >> 1) > cbWriteSize)
{
_outputBuffer.shrink_to_fit();
}
Expand Down

0 comments on commit aa5459d

Please sign in to comment.