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

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add bump memory context type and use it for tuplesorts
Date: 2024-04-16 11:01:28
Message-ID: CAApHDvqerXpzUnuDQfUEi3DZA+9=Ud9WSt3ruxN5b6PcOosx2g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 8 Apr 2024 at 00:37, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> I've now pushed all 3 patches. Thank you for all the reviews on
> these and for the extra MemoryContextMethodID bit, Matthias.

I realised earlier today when working on [1] that bump makes a pretty
brain-dead move when adding dedicated blocks to the blocks list. The
problem is that I opted to not have a current block field in
BumpContext and just rely on the head pointer of the blocks list to be
the "current" block. The head block is the block we look at to see if
we've any space left when new allocations come in. The problem there
is when adding a dedicated block in BumpAllocLarge(), the code adds
this to the head of the blocks list so that when a new allocation
comes in that's normal-sized, the block at the top of the list is full
and we have to create a new block for the allocation.

The attached fixes this by pushing these large/dedicated blocks to the
*tail* of the blocks list. This means the partially filled block
remains at the head and is available for any new allocation which will
fit. This behaviour is evident by the regression test change that I
added earlier today when working on [1]. The 2nd and smaller
allocation in that text goes onto the keeper block rather than a new
block.

I plan to push this tomorrow.

David

[1] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=bea97cd02ebb347ab469b78673c2b33a72109669

Attachment Content-Type Size
v1-0001-Push-dedicated-BumpBlocks-to-the-tail-of-the-bloc.patch text/plain 2.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amul Sul 2024-04-16 11:04:54 Re: Add bump memory context type and use it for tuplesorts
Previous Message Alexander Korotkov 2024-04-16 10:52:26 Re: Table AM Interface Enhancements