| 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-09-16 09:16:02 |
| Message-ID: | 9e81a344-b927-41e2-acea-da444a03aaa0@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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.
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 |
|---|---|---|
| v3-0001-Rename-PGAlignedXLogBlock-to-PGIOAlignedXLogBlock.patch | text/plain | 4.9 KB |
| v3-0002-Use-C11-alignas-instead-of-palloc-malloc-for-alig.patch | text/plain | 11.0 KB |
| v3-0003-XXX-Reintroduce-PGAlignedXLogBlock-and-use-it.patch | text/plain | 6.9 KB |
| v3-0004-Add-an-assertion-and-comments-for-HEADER_SCRATCH_.patch | text/plain | 2.0 KB |
| v3-0005-Avoid-static-variables-in-XLogRecordAssemble.patch | text/plain | 5.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Manuel Reyes Bravo | 2026-09-16 09:20:29 | Re: Distinguish publication exclusions in object addresses |
| Previous Message | shveta malik | 2026-09-16 09:07:04 | Re: [PATCH] Release replication slot on error in SQL-callable slot functions |