pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Use bump memory context for tuplesorts
4+ messages / 4 participants
[nested] [flat]

Commits from this thread:
  2024-04-07 705ec05653  Fix incorrect KeeperBlock macro in bump.c
* pgsql: Use bump memory context for tuplesorts
@ 2024-04-07 12:32  David Rowley <drowley@postgresql.org>
  0 siblings, 1 reply; 4+ messages in thread

From: David Rowley @ 2024-04-07 12:32 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Use bump memory context for tuplesorts

29f6a959c added a bump allocator type for efficient compact allocations.
Here we make use of this for non-bounded tuplesorts to store tuples.
This is very space efficient when storing narrow tuples due to bump.c
not having chunk headers.  This means we can fit more tuples in work_mem
before spilling to disk, or perform an in-memory sort touching fewer
cacheline.

Author: David Rowley
Reviewed-by: Nathan Bossart
Reviewed-by: Matthias van de Meent
Reviewed-by: Tomas Vondra
Reviewed-by: John Naylor
Discussion: https://postgr.es/m/CAApHDvqGSpCU95TmM=Bp=6xjL_nLys4zdZOpfNyWBk97Xrdj2w@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6ed83d5fa55cf6e6c9d1be34ec10730c48eba763

Modified Files
--------------
src/backend/utils/sort/tuplesort.c         | 52 +++++++++++++++++-------------
src/backend/utils/sort/tuplesortvariants.c | 38 +++++++++++++++++++---
src/include/utils/tuplesort.h              | 21 +++++++++---
3 files changed, 78 insertions(+), 33 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Use bump memory context for tuplesorts
@ 2024-04-07 15:28  Melanie Plageman <melanieplageman@gmail.com>
  parent: David Rowley <drowley@postgresql.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Melanie Plageman @ 2024-04-07 15:28 UTC (permalink / raw)
  To: David Rowley <drowley@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

On Sun, Apr 7, 2024 at 8:32 AM David Rowley <drowley@postgresql.org> wrote:
>
> Use bump memory context for tuplesorts
>
> 29f6a959c added a bump allocator type for efficient compact allocations.
> Here we make use of this for non-bounded tuplesorts to store tuples.
> This is very space efficient when storing narrow tuples due to bump.c
> not having chunk headers.  This means we can fit more tuples in work_mem
> before spilling to disk, or perform an in-memory sort touching fewer
> cacheline.

Looks like this assert is tripping on grison [1].

running bootstrap script ... TRAP: failed Assert("total_allocated ==
context->mem_allocated"), File: "bump.c", Line: 808, PID: 30248

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=grison&dt=2024-04-07%2014%3A10%3A09





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Use bump memory context for tuplesorts
@ 2024-04-07 17:52  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Melanie Plageman <melanieplageman@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2024-04-07 17:52 UTC (permalink / raw)
  To: Melanie Plageman <melanieplageman@gmail.com>; +Cc: David Rowley <drowley@postgresql.org>; pgsql-committers@lists.postgresql.org

Melanie Plageman <melanieplageman@gmail.com> writes:
> Looks like this assert is tripping on grison [1].

> running bootstrap script ... TRAP: failed Assert("total_allocated ==
> context->mem_allocated"), File: "bump.c", Line: 808, PID: 30248

The same on mamba.  However, I failed to duplicate it in an x86
(32-bit) VM.  I think the critical factor on the failing machines
is that MAXALIGN is 8 which is more than their sizeof(pointer).

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Use bump memory context for tuplesorts
@ 2024-04-07 21:11  Andres Freund <andres@anarazel.de>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Andres Freund @ 2024-04-07 21:11 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Melanie Plageman <melanieplageman@gmail.com>; David Rowley <drowley@postgresql.org>; pgsql-committers@lists.postgresql.org

Hi,

On 2024-04-07 13:52:28 -0400, Tom Lane wrote:
> Melanie Plageman <melanieplageman@gmail.com> writes:
> > Looks like this assert is tripping on grison [1].
>
> > running bootstrap script ... TRAP: failed Assert("total_allocated ==
> > context->mem_allocated"), File: "bump.c", Line: 808, PID: 30248
>
> The same on mamba.  However, I failed to duplicate it in an x86
> (32-bit) VM.  I think the critical factor on the failing machines
> is that MAXALIGN is 8 which is more than their sizeof(pointer).

For posterity: I think the above is correct, and that I found the concrete
reason this causes issues on the thread related to the patch. I posted there
because I figured it out after looking at Tomas' gdb output:

https://postgr.es/m/20240407210924.fvwfwbzms3bvtfcd%40awork3.anarazel.de

- Andres





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2024-04-07 21:11 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-04-07 12:32 pgsql: Use bump memory context for tuplesorts David Rowley <drowley@postgresql.org>
2024-04-07 15:28 ` Melanie Plageman <melanieplageman@gmail.com>
2024-04-07 17:52   ` Tom Lane <tgl@sss.pgh.pa.us>
2024-04-07 21:11     ` Andres Freund <andres@anarazel.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox