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

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment
Дата
Msg-id CAApHDvqvFVd5LyKcNpY5cdBg5_ecZj=P7aNZwh2MMv+GK-7zEg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment  (Andres Freund <andres@anarazel.de>)
Ответы Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment
Список pgsql-hackers
On Wed, 16 Nov 2022 at 08:19, Andres Freund <andres@anarazel.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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Yugo NAGATA
Дата:
Сообщение: Re: BUG #17434: CREATE/DROP DATABASE can be executed in the same transaction with other commands
Следующее
От: vignesh C
Дата:
Сообщение: Re: PGDOCS - Logical replication GUCs - added some xrefs