This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Use zlib::compress which operates on std::unique_ptr<uint8_t[]>
AbandonedPublic

Authored by MaskRay on Aug 2 2018, 9:59 PM.

Details

Summary

zlib::compress on SmallVectorImpl<char> uses compressBound() to compute
the upper bound of the compressed buffer (larger than the source),
allocates initialized (zeroed) SmallVectorImpl<char>, which makes every
allocated page resident.

However, the actual size of the compressed buffer is usually much
smaller. Making every page resident is wasteful.

std::unique_ptr<uint8_t[]> backed buffer is uninitialized and avoids
redundant resident pages.

For a test binary with ~1.9GiB uncompressed debug info, this optimization
decreases max RSS by ~1.5GiB.

Event Timeline

MaskRay created this revision.Aug 2 2018, 9:59 PM
MaskRay abandoned this revision.Aug 3 2018, 12:37 PM

https://reviews.llvm.org/D50223 has been changed to improve zlib::compress's current SmallVectorImpl interface. This is no longer relevant.