Re: pg_basebackup: removed an unnecessary use of memset in FindStreamingStart - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: pg_basebackup: removed an unnecessary use of memset in FindStreamingStart
Date
Msg-id BEF8A8ED-11D7-4D99-941C-85B3FDDC3249@yesql.se
Whole thread Raw
In response to Re: pg_basebackup: removed an unnecessary use of memset in FindStreamingStart  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: pg_basebackup: removed an unnecessary use of memset in FindStreamingStart
List pgsql-hackers
> On 25 Feb 2026, at 13:41, Chao Li <li.evan.chao@gmail.com> wrote:
>
>> On Feb 25, 2026, at 18:21, Daniel Gustafsson <daniel@yesql.se> wrote:
>>
>>> On 25 Feb 2026, at 07:31, yangyz <1197620467@qq.com> wrote:
>>
>>> 2.Performance Overhead
>>> In each iteration, the entire buffer of size LZ4_CHUNK_SZ (potentially several megabytes) is zero-initialized.
Sincethese memory blocks are immediately overwritten by decompressed data, this zeroing operation constitutes an
unnecessaryconsumption of CPU resources. 
>>
>> When proposing a performance improvement it's important to provide some level
>> of benchmarks to show the improvement. Is removing this memset noticeable?
>
> I don’t think this patch is about performance. Although removing the memset might save a few CPU cycles, the real
benefitseems to be cleanup and consistency. The memset appears unnecessary, and similar functions don’t use it, so I
thinkthis change mainly improves maintainability. 

I would argue the opposite, clearing a buffer before passing it to an external
library function writing to it seems the right thing to do unless it can be
proven to regress performance too much.  Also, "appears unnecessary" doesn't
instill enough confidence to perform a change IMO.

--
Daniel Gustafsson




pgsql-hackers by date:

Previous
From: Zsolt Parragi
Date:
Subject: Re: centralize CPU feature detection
Next
From: Zsolt Parragi
Date:
Subject: Re: Improve OAuth discovery logging