From 1f82f0f8c44b9035420b1d9b9800fc9008fa15d7 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 17 Dec 2022 13:00:48 +0100 Subject: pkg/image: optimize image decompression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- executor/common_zlib.h | 1 + 1 file changed, 1 insertion(+) (limited to 'executor') 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) -- cgit mrf-deployment