From 537846afd9f7183b81c9554b626476fb6c2dd622 Mon Sep 17 00:00:00 2001 From: yangyuanzhuo <1197620467@qq.com> Date: Wed, 25 Feb 2026 14:02:38 +0800 Subject: [PATCH v1] Removed an unnecessary use of memset in FindStreamingStart When out_size is passed as an input parameter, it denotes the size of the output buffer (outbuf). The decompression operation writes the decompressed data to outbuf. Upon function return, out_size is updated to reflect the actual number of bytes written. Notably, even in cases of partial decompression, data is written starting from the initial position of outbuf. In each iteration, the entire buffer of size LZ4_CHUNK_SZ (potentially several megabytes) is zero-initialized. Since these memory blocks are immediately overwritten by decompressed data, this zeroing operation constitutes an unnecessary consumption of CPU resources. Author: Yuanzhuo Yang <1197620467@qq.com> --- src/bin/pg_basebackup/pg_receivewal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c index ddfec29..f1d0294 100644 --- a/src/bin/pg_basebackup/pg_receivewal.c +++ b/src/bin/pg_basebackup/pg_receivewal.c @@ -413,7 +413,6 @@ FindStreamingStart(uint32 *tli) size_t out_size = LZ4_CHUNK_SZ; size_t read_size = readend - readp; - memset(outbuf, 0, LZ4_CHUNK_SZ); status = LZ4F_decompress(ctx, outbuf, &out_size, readp, &read_size, &dec_opt); if (LZ4F_isError(status)) -- 1.8.3.1