Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Smith, Peter" <peters(at)fast(dot)au(dot)fujitsu(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays
Date: 2019-10-01 16:49:16
Message-ID: 20191001164916.im42lcdthvudmasy@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2019-10-01 12:17:08 -0400, Tom Lane wrote:
> FYI, I checked into whether this would result in worse generated code.
> In the one place I checked (InsertPgAttributeTuple, which hopefully
> is representative), I got *exactly the same* assembly code before
> and after, on both a somewhat-aging gcc and fairly modern clang.
> Hadn't quite expected that, but it removes any worries about whether
> we might be losing anything.

I think the only case where it's plausible to be really worse is where
we intentionally leave part of such allocations uninitialized - which we
can't easily do in these cases because the rest of the struct will also
get zeroed out. The compiler will probably figure it out in some cases,
but there's plenty where it can't. But I don't think there's many
places like that in our code though.

> Note though that InsertPgAttributeTuple uses memset(), while some of
> these other places use MemSet(). The code I see being generated for
> MemSet() is also the same(!) on clang, but it is different and
> probably worse on gcc. I wonder if it isn't time to kick MemSet to
> the curb. We have not re-evaluated that macro in more than a dozen
> years, and compilers have surely changed.

Yes, we really should!

- Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2019-10-01 17:41:43 Re: pgsql: Implement jsonpath .datetime() method
Previous Message Bruce Momjian 2019-10-01 16:19:36 Re: Value of Transparent Data Encryption (TDE)