Commit 6bb90698 authored by Nick Terrell's avatar Nick Terrell Committed by Facebook Github Bot

Fix zlib + lzma memory usage inefficiency

Summary:
Since IOBuf rounds to a good malloc size, zlib and lzma waste space.
For a 4 MiB `length`, about 1 MiB of the IOBuf is wasted.

Reviewed By: yfeldblum

Differential Revision: D4872830

fbshipit-source-id: 42fc83277b2dae22b75403e0e71c43e8f2b19f21
parent 6dbd9e97
......@@ -840,7 +840,7 @@ std::unique_ptr<IOBuf> ZlibCodec::addOutputBuffer(z_stream* stream,
CHECK_EQ(stream->avail_out, 0);
auto buf = IOBuf::create(length);
buf->append(length);
buf->append(buf->capacity());
stream->next_out = buf->writableData();
stream->avail_out = buf->length();
......@@ -1147,7 +1147,7 @@ std::unique_ptr<IOBuf> LZMA2Codec::addOutputBuffer(
CHECK_EQ(stream->avail_out, 0);
auto buf = IOBuf::create(length);
buf->append(length);
buf->append(buf->capacity());
stream->next_out = buf->writableData();
stream->avail_out = buf->length();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment