| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Cc: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andres Freund <andres(at)anarazel(dot)de> |
| Subject: | Re: Use C11 alignas instead of palloc/malloc for alignment |
| Date: | 2026-10-19 07:20:47 |
| Message-ID: | 8bdc9593-cbe1-4c61-abe0-732cc8724acb@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 16.09.26 11:16, Peter Eisentraut wrote:
> On 08.09.26 12:08, Peter Eisentraut wrote:
>> There are a number of places where palloc()/malloc()/etc. was used
>> solely to obtain an aligned buffer. We can do these much simpler by
>> using alignas with a local variable instead. See attached patch.
>
> Here is a new patch set that aims to address all the comments.
Here is a rebased patch set. No functional changes over v3.
>
> First of all, while changing this to make use of the existing
> "AlignedBlock" types, I noticed that PGAlignedXLogBlock is misnamed: It
> should be PGIOAlignedXLogBlock, to maintain the similarity with
> PGAlignedBlock and PGIOAlignedBlock, respectively. So I'm proposing to
> rename it in patch 0001.
>
> We could then re-introduce the "correct" PGAlignedXLogBlock and make use
> of it, which is patch 0003. But I'm hesitant to change the meaning of
> PGAlignedXLogBlock without some gap in between, so I'm not sure about
> this patch.
>
> Patch 0002 is as before, but with the "AlignedBlock" types used, and the
> copy_file() change backed out and a comment added.
>
> Patch 0004 adds some comments and an assertion for HEADER_SCRATCH_SIZE,
> and patch 0005 refactors things to convert the workspace from static
> variable to a normal (non-static) local variable. (This could be
> squashed into 0002, but it seems cleaner to review this way at least.)
>
> (The pgindent changes were already committed separately.)
| Attachment | Content-Type | Size |
|---|---|---|
| v4-0001-Rename-PGAlignedXLogBlock-to-PGIOAlignedXLogBlock.patch | text/plain | 4.9 KB |
| v4-0002-Use-C11-alignas-instead-of-palloc-malloc-for-alig.patch | text/plain | 11.0 KB |
| v4-0003-XXX-Reintroduce-PGAlignedXLogBlock-and-use-it.patch | text/plain | 6.9 KB |
| v4-0004-Add-an-assertion-and-comments-for-HEADER_SCRATCH_.patch | text/plain | 2.0 KB |
| v4-0005-Avoid-static-variables-in-XLogRecordAssemble.patch | text/plain | 5.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Vaibhav Dalvi | 2026-10-19 07:20:54 | Re: walreceiver: stale hot_standby_feedback xmin on primary when wal_receiver_status_interval = 0 (PG16 and later) |
| Previous Message | shveta malik | 2026-10-19 07:10:52 | Re: Publication of same parent table with ONLY-ness mismatch should error |