Optimize ZlibCodec::doUncompress()
Summary:
`ZlibCodec::doUncompress()` always allocates at least 4 MiB when the uncompressed size is unkown.
We can get a 10-20% speed boost for small inputs (as well as significant memory savings) if we dynamically choose the buffer size.
Benchmarks before the change:
============================================================================
experimental/terrelln/CompressionBenchmark.cpp relative time/iter iters/s
============================================================================
uncompress(ZLIB_100) 2.96us 338.19K
uncompress(ZLIB_1000) 7.22us 138.44K
uncompress(ZLIB_10000) 36.86us 27.13K
uncompress(ZLIB_100000) 299.70us 3.34K
uncompress(ZLIB_1000000) 2.74ms 365.32
uncompress(ZLIB_10000000) 26.91ms 37.16
uncompress(ZLIB_100000000) 273.92ms 3.65
============================================================================
After:
============================================================================
experimental/terrelln/CompressionBenchmark.cpp relative time/iter iters/s
============================================================================
uncompress(ZLIB_100) 2.34us 426.68K
uncompress(ZLIB_1000) 6.24us 160.38K
uncompress(ZLIB_10000) 35.52us 28.16K
uncompress(ZLIB_100000) 296.30us 3.37K
uncompress(ZLIB_1000000) 2.74ms 365.25
uncompress(ZLIB_10000000) 27.16ms 36.82
uncompress(ZLIB_100000000) 273.72ms 3.65
============================================================================
Reviewed By: yfeldblum
Differential Revision:
D4783871
fbshipit-source-id:
0fcce191ea520fd2117551db679c86f5ff734893