Re: Backend memory dump analysis

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Backend memory dump analysis
Дата
Msg-id 6421.1522194949@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Backend memory dump analysis  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Ответы Re: Backend memory dump analysis  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Список pgsql-hackers
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
> How about this one as well:

>     portal->portalContext = AllocSetContextCreate(TopPortalContext,
>                                                   "PortalContext",
>                                                   ALLOCSET_SMALL_SIZES);
> +   MemoryContextCopySetIdentifier(portal->portalContext, name);

Seems reasonable, although I think if you were to delay setting the
name till the end of that function, you could point to portal->name
and avoid the extra pstrdup.  Maybe that's useless microoptimization.

> The term CopySetIdentifier has confused me a bit.  (What's a "set
> identifier"?)  Maybe use CopyAndSetIdentifier?  (We similarly have
> MemoryContextResetAndDeleteChildren.)

No objection, do you want to make the change?

> I'm also not clear why this doesn't undo the previous optimization that
> preferred making the identifier a compile time-constant.  Aren't we now
> just going back to doing a pstrdup() every time?

Huh?  It's not undoing that, it's doubling down on it; the "name" now
*has* to be a compile-time constant.  Only for contexts that seem worthy
of carrying extra ID information, which is a small minority, do we bother
setting the ident field.  Even for those, in the majority of cases we can
avoid an extra strcpy because the identity info is being carried somewhere
inside the context already.

            regards, tom lane


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Backend memory dump analysis
Следующее
От: Haribabu Kommi
Дата:
Сообщение: Re: PQHost() undefined behavior if connecting string contains bothhost and hostaddr types