[PATCH] D121512: [Support] zlib::compress: replace compress2 with iterative deflate
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 12 13:39:17 PST 2022
MaskRay added a comment.
In D121512#3377419 <https://reviews.llvm.org/D121512#3377419>, @joerg wrote:
> `compressBound` gives the maximum possible size for the output, so of course it can be larger than the input. In combination with `resize_for_overwrite`, that should be cheaper than possible multiple copies for the loop if there is even a slight chance that the data doesn't compress that well. The code complexity is certainly much higher. The only expected error from `compress2` here is `Z_MEM_ERROR` when it can't allocate the dictionary etc. As such, we could convert that one into a fatal error easily.
The chance that 0.5*N needs reallocation is very slow (for some large executables, all input .debug_* sections can compress to 55%. Most are smaller than 40%). In most cases the allocated buffer will save more than one half.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121512/new/
https://reviews.llvm.org/D121512
More information about the llvm-commits
mailing list