Re: Missed compiler optimization issue in function select_rtable_names_for_explain

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: XChy <xxs_chy(at)outlook(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Missed compiler optimization issue in function select_rtable_names_for_explain
Date: 2024-05-22 10:55:48
Message-ID: 23848714-3662-428E-8E6D-5986D87491D6@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On 22 May 2024, at 12:12, XChy <xxs_chy(at)outlook(dot)com> wrote:
>
>> How is the memset in select_rtable_names_for_explain a dead-store? Even memset calls could be optimized away from the EXPLAIN codepath I have a feeling it
>> would have to be many in a tight loop for it to be measurable even?

> For the first question, I don't mean that the memset is the dead store.

Gotcha

> I mean that the stores with value "0" after the memset are dead:
> ```
> dpns.subplans = NIL;
> dpns.ctes = NIL;
> dpns.appendrels = NULL;
> ```
> since the memset has written zeroes to the object "dpns", and these members are known to be zero.

They are known to be zero, but that's not entirely equivalent though is it?
NIL is defined as ((List *) NULL) and NULL is typically defined as ((void *)
0), so sizeof(0) would be the size of an int and sizeof(NULL) would be the size
of a void pointer.

--
Daniel Gustafsson

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2024-05-22 11:00:12 Re: Missed compiler optimization issue in function select_rtable_names_for_explain
Previous Message o1bigtenor 2024-05-22 10:53:02 Re: Regarding use case of epoch to generate nanoseconds precision