Re: [HACKERS] PATCH: two slab-like memory allocators

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: [HACKERS] PATCH: two slab-like memory allocators
Дата
Msg-id 20170228051630.3qcevakcaaa6b4ef@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: [HACKERS] PATCH: two slab-like memory allocators  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [HACKERS] PATCH: two slab-like memory allocators  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

On 2017-02-27 22:57:24 -0500, Tom Lane wrote:
> If the slab allocator would be happier with just a MemoryContext pointer
> as chunk header, I think we should push in this direction rather than
> invent some short-term hack.

It would - it really doesn't need the size, because it's the same for
the whole context, and thereby is a waste of space.  Still wondering if
we should band-aid this till that's done.


> One could imagine redefining aset.c's chunk header along the lines of
> 
> typedef struct AllocSetChunkHeader
> {
>     Size        size;             /* size of data space allocated in chunk */
> #ifdef MEMORY_CONTEXT_CHECKING
>     Size        requested_size;   /* original request size */
> #if 32-bit-but-maxalign-is-8
>     Size        padding;          /* needed to avoid padding below */
> #endif
> #endif
>     MemoryContext context;        /* owning context */
>     /* there must not be any padding to reach a MAXALIGN boundary here! */
> } AllocSetChunkHeader;
> 
> where we'd possibly need some help from configure to implement that inner
> #if condition, but it seems doable enough.

Hm, that should be doable with something like
#if MAXIMUM_ALIGNOF > 4 && SIZEOF_VOID_P == 4

which'd probably be better documentation than a macro that hides this
(arguing internally whether SIZEOF_VOID_P or SIZEOF_SIZE_T) is better.

Working on a patch now, will post but not push tonight.

Greetings,

Andres Freund



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

Предыдущее
От: Beena Emerson
Дата:
Сообщение: Re: [HACKERS] increasing the default WAL segment size
Следующее
От: Alvaro Herrera
Дата:
Сообщение: [HACKERS] avoid bloat from CREATE INDEX CONCURRENTLY