pgsql: Avoid trying to release a List's initial allocation via repalloc

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Avoid trying to release a List's initial allocation via repalloc
Дата
Msg-id E1iH93Q-0002YD-FW@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Avoid trying to release a List's initial allocation via repalloc().

Commit 1cff1b95a included some code that supposed it could repalloc()
a memory chunk to a smaller size without risk of the chunk moving.
That was not a great idea, because it depended on undocumented behavior
of AllocSetRealloc, which commit c477f3e44 changed thereby breaking it.
(Not to mention that this code ought to work with other memory context
types, which might not work the same...)  So get rid of the repalloc
calls, and instead just wipe the now-unused ListCell array and/or tell
Valgrind it's NOACCESS, as if we'd freed it.

In cases where the initial list allocation had been quite large, this
could represent an annoying waste of space.  In principle we could
ameliorate that by allocating the initial cell array separately when
it exceeds some threshold.  But that would complicate new_list() which
is hot code, and the returns would materialize only in narrow cases.
On balance I don't think it'd be worth it.

Discussion: https://postgr.es/m/17059.1570208426@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ac12ab06a96179d44046494bc76ec53f30b5d30a

Modified Files
--------------
src/backend/nodes/list.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)


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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: pgsql: Change MemoryContextMemAllocated to return Size
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Doc: improve docs about pg_statistic_ext_data.