Re: Add bump memory context type and use it for tuplesorts

Поиск
Список
Период
Сортировка
От Matthias van de Meent
Тема Re: Add bump memory context type and use it for tuplesorts
Дата
Msg-id CAEze2WhYg_hgeMcBHVnsb=QFWVGQN7GqmATOWU_0PxEZ2_DVVA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Add bump memory context type and use it for tuplesorts  (David Rowley <dgrowleyml@gmail.com>)
Ответы Re: Add bump memory context type and use it for tuplesorts  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-hackers
On Tue, 20 Feb 2024 at 11:02, David Rowley <dgrowleyml@gmail.com> wrote:
> On Fri, 26 Jan 2024 at 01:29, Matthias van de Meent
> <boekewurm+postgres@gmail.com> wrote:
> > >> +    allocSize = MAXALIGN(sizeof(BumpContext)) + Bump_BLOCKHDRSZ +
> > >> +    if (minContextSize != 0)
> > >> +        allocSize = Max(allocSize, minContextSize);
> > >> +    else
> > >> +        allocSize = Max(allocSize, initBlockSize);
> >
> > Shouldn't this be the following, considering the meaning of "initBlockSize"?
>
> No, we want to make the blocksize exactly initBlockSize if we can. Not
> initBlockSize plus all the header stuff.  We do it that way for all
> the other contexts and I agree that it's a good idea as it keeps the
> malloc request sizes powers of 2.

One part of the reason of my comment was that initBlockSize was
ignored in favour of minContextSize if that was configured, regardless
of the value of initBlockSize. Is it deliberately ignored when
minContextSize is set?

> > >> + * BumpFree
> > >> + *        Unsupported.
> > >> [...]
> > >> + * BumpRealloc
> > >> + *        Unsupported.
> >
> > Rather than the error, can't we make this a no-op (potentially
> > optionally, or in a different memory context?)
>
> Unfortunately not.  There are no MemoryChunks on bump chunks so we've
> no way to determine the context type a given pointer belongs to.  I've
> left the MemoryChunk on there for debug builds so we can get the
> ERRORs to allow us to fix the broken code that is pfreeing these
> chunks.
>
> > I understand that allowing pfree/repalloc in bump contexts requires
> > each allocation to have a MemoryChunk prefix in overhead, but I think
> > it's still a valid use case to have a very low overhead allocator with
> > no-op deallocator (except context reset). Do you have performance
> > comparison results between with and without the overhead of
> > MemoryChunk?
>
> Oh right, you've taken this into account.  I was hoping not to have
> the headers otherwise the only gains we see over using generation.c is
> that of the allocation function being faster.
>
> [...]  The smaller the tuple, the
> more that will be noticeable as the chunk header is a larger portion
> of the overall allocation with those.

I see. Thanks for the explanation.

Kind regards,

Matthias van de Meent
Neon (https://neon.tech)



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

Предыдущее
От: Dilip Kumar
Дата:
Сообщение: Re: logical decoding and replication of sequences, take 2
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Have pg_basebackup write "dbname" in "primary_conninfo"?