From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Should CreateExprContext() be using ALLOCSET_DEFAULT_SIZES? |
Date: | 2023-05-05 13:10:24 |
Message-ID: | 11EE0126-9D2B-4AB7-AA98-2AF55F3551E9@yesql.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On 17 Feb 2023, at 05:01, Andres Freund <andres(at)anarazel(dot)de> wrote:
> ISTM that we really shouldn't use ALLOCSET_DEFAULT_SIZES for expression
> contexts, as they most commonly see only a few small, or no, allocations.
Looking into this I think you are correct.
> ISTM that we could save a reasonable amount of memory by using a smaller
> initial size.
I experimented with the below trivial patch in CreateExprContext:
- return CreateExprContextInternal(estate, ALLOCSET_DEFAULT_SIZES);
+ return CreateExprContextInternal(estate, ALLOCSET_START_SMALL_SIZES);
Across various (unscientific) benchmarks, including expression heavy TPC-H
queries, I can see consistent reductions in memory use and tiny (within the
margin of error) increases in performance. More importantly, I didn't see a
case of slowdowns with this applied or any adverse effects in terms of memory
use. Whenever the initial size isn't big enough the expr runtime is likely
exceeding the overhead from growing the allocation?
--
Daniel Gustafsson
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Sjöblom | 2023-05-05 13:17:31 | [DOC] Update ALTER SUBSCRIPTION documentation |
Previous Message | Michael Paquier | 2023-05-05 12:30:11 | Re: Fix typos and inconsistencies for v16 |