Re: Should CreateExprContext() be using ALLOCSET_DEFAULT_SIZES?

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