Re: Backend memory dump analysis - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Backend memory dump analysis
Date
Msg-id 6421.1522194949@sss.pgh.pa.us
Whole thread Raw
In response to Re: Backend memory dump analysis  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: Backend memory dump analysis  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List 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 by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Backend memory dump analysis
Next
From: Haribabu Kommi
Date:
Subject: Re: PQHost() undefined behavior if connecting string contains bothhost and hostaddr types