From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment |
Date: | 2022-11-16 10:56:26 |
Message-ID: | CAApHDvqvFVd5LyKcNpY5cdBg5_ecZj=P7aNZwh2MMv+GK-7zEg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 16 Nov 2022 at 08:19, Andres Freund <andres(at)anarazel(dot)de> wrote:
> We already rely on memory context returning MAXIMUM_ALIGNOF aligned
> allocations. Adding the special case, I think, means that the we could safely
> over-allocate by "only"
> alignto + sizeof(MemoryChunk) - MAXIMUM_ALIGNOF
>
> Which would be a reasonable win for small allocations with a small >
> MAXIMUM_ALIGNOF alignment. But I don't think that'll be a very common case?
Seems reasonable. Subtracting MAXIMUM_ALIGNOF doesn't add any
additional run-time cost since it will be constant folded with the
sizeof(MemoryChunk).
I've attached an updated patch. The 0002 is just intended to exercise
these allocations a little bit, it's not intended for commit. I was
using that to ensure valgrind does not complain about anything. It
seems happy now.
David
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Add-allocator-support-for-larger-allocation-align.patch | text/plain | 14.8 KB |
v2-0002-Test-code-to-exercise-palloc_aligned-and-repalloc.patch | text/plain | 1.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | vignesh C | 2022-11-16 11:24:34 | Re: PGDOCS - Logical replication GUCs - added some xrefs |
Previous Message | Yugo NAGATA | 2022-11-16 10:53:02 | Re: BUG #17434: CREATE/DROP DATABASE can be executed in the same transaction with other commands |