Hi Hackers,
When I read the FindStreamingStart function in pg_receivewal.c, I discovered an unnecessary use of memset.So I removed it, optimizing the performance without affecting its functionality. The following is the detailed analysis of the reasons: 1.LZ4F_decompress will fully overwrite the output buffer: 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. 2.Performance Overhead 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. Regards, Yang Yuanzhuo
v1-0001-Removed-an-unnecessary-use-of-memset-in-FindStrea.patch
Description: Binary data
