Re: Reduce TupleHashEntryData struct size by half

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Reduce TupleHashEntryData struct size by half
Date: 2025-02-08 01:13:06
Message-ID: 09b325921e50bc3a3217fb01d8eb512c89ee36f1.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 2025-01-12 at 14:54 +1300, David Rowley wrote:
> I wonder if there's some other better way of doing this. Would it be
> worth having some function like ExecCopySlotMinimalTuple() that
> accepts an additional parameter so that the palloc allocates N more
> bytes at the end?

Attached a new series that implements this idea.

I also added in the change to use the Bump allocator for the tablecxt.
In my simple test, the whole patch series reduces HashAgg memory usage
by more than 40% and increases speed by a few percent.

In your test, patch 0003 seemed to have a regression, but then 0007
made up for it (and maybe a hair faster). I investigated, but the
profile was a bit misleading so I'm not clear on why 0003 came out
slower. I can investigate further, but the primary purpose of this
patch series is reducing memory usage, so as long as the overall series
has no regression then I think it's fine.

Regards,
Jeff Davis

Attachment Content-Type Size
v6-0001-Create-accessor-functions-for-TupleHashEntry.patch text/x-patch 10.8 KB
v6-0002-Add-ExecCopySlotMinimalTupleExtra.patch text/x-patch 10.9 KB
v6-0003-Store-additional-data-after-mintuple.patch text/x-patch 2.4 KB
v6-0004-simplehash-don-t-require-a-status-field.patch text/x-patch 7.1 KB
v6-0005-TupleHashTable-reduce-overhead-by-removing-status.patch text/x-patch 4.9 KB
v6-0006-Pack-TupleHashEntryData-and-AggStatePerGroupData.patch text/x-patch 1.5 KB
v6-0007-HashAgg-use-Bump-allocator-for-hash-TupleHashTabl.patch text/x-patch 10.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2025-02-08 01:15:37 Re: Incorrect CHUNKHDRSZ in nodeAgg.c
Previous Message M vd H 2025-02-08 00:53:35 BgBufferSync(): clarification about reusable_buffers variable