Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment

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-08 03:53:49
Message-ID: CAApHDvpfm7SnRLgvRZj4QEHYEQGeZ=oUeBbcJ9RNHaErPR6eWg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 8 Nov 2022 at 14:57, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> On Tue, 8 Nov 2022 at 05:24, Andres Freund <andres(at)anarazel(dot)de> wrote:
> > Should we handle the case where we get a suitably aligned pointer from
> > MemoryContextAllocExtended() differently?
>
> Maybe it would be worth the extra check. I'm trying to imagine future
> use cases. Maybe if someone wanted to ensure that we're aligned to
> CPU cache line boundaries then the chances of the pointer already
> being aligned to 64 bytes is decent enough. The problem is it that
> it's too late to save any memory, it just saves a bit of boxing and
> unboxing of the redirect headers.

Thinking about that a bit more, if we keep the repalloc support then
we can't do this as if we happen to get the right alignment by chance
during the palloc_aligned, then if we don't have the redirection
MemoryChunk, then we've no way to ensure we keep the alignment after a
repalloc.

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2022-11-08 03:54:25 Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment
Previous Message Hayato Kuroda (Fujitsu) 2022-11-08 03:51:23 RE: Perform streaming logical transactions by background workers and parallel apply