Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
Date: 2022-07-07 11:00:15
Message-ID: 9847b13c-b785-f4e2-75c3-12ec77a3b05c@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 18.05.22 15:52, Peter Eisentraut wrote:
> On 18.05.22 01:18, Justin Pryzby wrote:
>> Take the first one as an example.  It says:
>>
>>          GenericCosts costs;
>>          MemSet(&costs, 0, sizeof(costs));
>>
>> You sent a patch to change it to sizeof(GenericCosts).
>>
>> But it's not a pointer, so they are the same.
>
> This instance can more easily be written as
>
>     costs = {0};

The attached patch replaces all MemSet() calls with struct
initialization where that is easily possible. (For example, some cases
have to worry about padding bits, so I left those.)

This reduces the number of MemSet() calls from about 400 to about 200.
Maybe this can help simplify the investigation of the merits of the
remaining calls.

Attachment Content-Type Size
0001-WIP-Replace-MemSet-calls-with-struct-initialization.patch text/plain 81.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Lepikhov 2022-07-07 11:11:06 Re: Condition pushdown: why (=) is pushed down into join, but BETWEEN or >= is not?
Previous Message Matthias van de Meent 2022-07-07 10:58:37 Re: Make name optional in CREATE STATISTICS