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-03-22 16:39:30
Message-ID: 1cc3b400a0e8eead18ff967436fa9e42c0c14cfb.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2025-03-04 at 17:28 -0800, Jeff Davis wrote:
> My results (with wide tables):
>
>                         GROUP BY      EXCEPT
>    master:                  2151        1732
>    entire v8 series:        2054        1740

I'm not sure what I did with the EXCEPT test, above, perhaps I had
filled the test table twice by mistake or something?

New numbers below:

Data:

create table c (a int not null);
insert into c select a from generate_Series(1,1000) a;

create table big(i int, j int);
insert into big select g, 1 from generate_series(1,10000000) g;

create table wide (t text not null);
insert into wide
select repeat(md5(a::text),10)
from generate_Series(1,1000) a;

create table wide_copy (t text not null);
insert into wide_copy select * from wide;

vacuum freeze analyze;

Results:

c(tps) wide(tps) except(tps) big(ms) big(MiB)

91ecb5e0bc 4768 2091 2317 3853 768
master 4942 2063 2323 3831 768
0001 4932 2038 2361 3712 616
0002 4601 2034 2365 3753 616
0003 4850 2040 2418 3749 616
0004 4744 2065 2282 3665 488
0005 4630 1994 2307 3665 488
0006 4809 2063 2394 3646 488
0007 4752 2070 2479 3659 488

Note: c.sql, wide.sql, and except.sql are measured in tps, higher is
better. big.sql is measured in ms and MiB, lower is better.

For some reason I'm getting a decline of about 3% in the c.sql test
that seems to be associated with the accessor functions, even when
inlined. I'm also not seeing as much benefit from the inlining of the
MemoryContextMemAllocated(). But these mixed test results are minor
compared with the memory savings of 35% and the more consistently-
improved performance of 5% on the larger test (which is also integers),
so I plan to commit it.

Regards,
Jeff Davis

Attachment Content-Type Size
v9-0001-HashAgg-use-Bump-allocator-for-hash-TupleHashTabl.patch text/x-patch 11.3 KB
v9-0002-Create-accessor-functions-for-TupleHashEntry.patch text/x-patch 14.5 KB
v9-0003-Inline-TupleHashEntryGetTuple-and-.GetAdditional.patch text/x-patch 4.9 KB
v9-0004-Remove-additional-pointer-from-TupleHashEntryData.patch text/x-patch 3.4 KB
v9-0005-Add-ExecCopySlotMinimalTupleExtra.patch text/x-patch 11.0 KB
v9-0006-Use-ExecCopySlotMinimalTupleExtra-to-avoid-a-memc.patch text/x-patch 2.4 KB
v9-0007-Inline-MemoryContextMemAllocated.patch text/x-patch 5.9 KB
c.sql application/sql 37 bytes
except.sql application/sql 51 bytes
wide.sql application/sql 40 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2025-03-22 17:07:55 Bug - DoS - Handler function lookups consider non-handler functions
Previous Message Tom Lane 2025-03-22 16:24:43 Re: query_id: jumble names of temp tables for better pg_stat_statement UX