Re: Should CreateExprContext() be using ALLOCSET_DEFAULT_SIZES?

Поиск
Список
Период
Сортировка
От Daniel Gustafsson
Тема Re: Should CreateExprContext() be using ALLOCSET_DEFAULT_SIZES?
Дата
Msg-id 11EE0126-9D2B-4AB7-AA98-2AF55F3551E9@yesql.se
обсуждение исходный текст
Ответ на Should CreateExprContext() be using ALLOCSET_DEFAULT_SIZES?  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
> On 17 Feb 2023, at 05:01, Andres Freund <andres@anarazel.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




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Fix typos and inconsistencies for v16
Следующее
От: Robert Sjöblom
Дата:
Сообщение: [DOC] Update ALTER SUBSCRIPTION documentation