Re: PGPROC alignment (was Re: pgsql: Separate RecoveryConflictReasons from procsignals)

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andres Freund <andres(at)anarazel(dot)de>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PGPROC alignment (was Re: pgsql: Separate RecoveryConflictReasons from procsignals)
Date: 2026-03-16 11:16:51
Message-ID: abfmoxoyep5jLnIc@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Hi,

On Mon, Mar 16, 2026 at 11:42:35AM +0100, Peter Eisentraut wrote:
> On 24.02.26 12:28, Bertrand Drouvot wrote:
> > > You can/should use C11 standard alignas(), so you don't need to worry about
> > > whether it's supported or not.
> >
> > Oh right, I did not notice 300c8f53247 and following like e7075a3405c, d4c0f91f7d5
> > and 97e04c74bed.
> >
> > PFA, 0001 doing so for PGPROC and PgAioUringContext. As those are typedef,
> > the patch puts alignas within the struct.
> >
> > For PGPROC at the start of the struct, I think that placing it on the first member
> > is the right location because it ensures the whole struct is aligned to PG_CACHE_LINE_SIZE
> > without adding padding before this member. For example if I set it on backendType,
> > then it adds 100 bytes of padding and the struct is obviously still a multiple of
> > PG_CACHE_LINE_SIZE but is now 1024 bytes (instead of 896).
> >
> > For PgAioUringContext at completion_lock (like suggested by Andres in [1]), which
> > is also the start of the struct.
> >
> > I checked and the padding for those are exactly the same after the changes.
>
> I have committed the 0001 patch.

Thanks! I don't know why but I don't see it in https://git.postgresql.org/gitweb/?p=postgresql.git;a=summary,
or in the github repo though.

> > 0002, is also making use of alignas in ItemPointerData, but this one is more
> > tricky so I'm not sure that's worth it (given the fact that we still need to
> > keep pg_attribute_aligned() as explained by Peter in [2]).
>
> This doesn't seem worth it to me. Let's skip it.

Yeah, that makes sense.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-03-16 12:06:41 pgsql: Remove unstable test for pg_statio_all_sequences stats reset
Previous Message Peter Eisentraut 2026-03-16 10:56:24 pgsql: Fix pg_upgrade failure when extension_control_path is used

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2026-03-16 11:19:34 Re: Report oldest xmin source when autovacuum cannot remove tuples
Previous Message Amit Kapila 2026-03-16 11:10:01 Re: Report bytes and transactions actually sent downtream