aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_zlib.h
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2022-12-17 13:00:48 +0100
committerDmitry Vyukov <dvyukov@google.com>2022-12-22 10:11:08 +0100
commit1f82f0f8c44b9035420b1d9b9800fc9008fa15d7 (patch)
treef77e5257a6056cea9e271127a0d7dd8b472d996f /executor/common_zlib.h
parenta0df376348d2ad1d3e557ea221e75c78a5d9fd96 (diff)
pkg/image: optimize image decompression
Benchmark results: name old time/op new time/op delta Decompress-8 24.7ms ± 1% 13.4ms ± 4% -45.81% (p=0.000 n=16+19) name old alloc/op new alloc/op delta Decompress-8 67.2MB ± 0% 0.0MB ± 1% -99.98% (p=0.000 n=18+20) name old allocs/op new allocs/op delta Decompress-8 188 ± 0% 167 ± 0% -11.17% (p=0.000 n=20+20) Test process memory consumption drops from 220MB to 80MB.
Diffstat (limited to 'executor/common_zlib.h')
-rw-r--r--executor/common_zlib.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/executor/common_zlib.h b/executor/common_zlib.h
index 24382ac0c..5d37cd0e0 100644
--- a/executor/common_zlib.h
+++ b/executor/common_zlib.h
@@ -476,6 +476,7 @@ static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcele
source += ZLIB_HEADER_WIDTH;
sourcelen -= ZLIB_HEADER_WIDTH;
+ // Note: pkg/image/compression.go also knows this const.
const unsigned long max_destlen = 132 << 20;
void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
if (ret == MAP_FAILED)