Re: Backend memory dump analysis
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Andres Freund <andres@anarazel.de>,
Vladimir Sitnikov <sitnikov.vladimir@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-03-27T17:29:14Z
Lists: pgsql-hackers
Alvaro Herrera <alvherre@alvh.no-ip.org> writes: > My only gripe is the pattern where the identifier needs to be > re-installed when resetting the context. I don't think we need to hold > push for that reason alone, but I bet we'll be revisiting that. Yeah, that's slightly annoying; if I'd found more than one case of that, I'd want a better answer. But it seems like contexts that are long-lived enough to warrant labeling typically don't get reset during their lifespans, so it shouldn't be a huge problem. I considered having MemoryContextReset either Assert that context->ident is NULL, or just forcibly reset it to NULL, thus preventing a dangling pointer if someone gets this wrong. But that would lock out a perfectly valid coding pattern where the identifier is in the parent context, so I'm not convinced it's a good idea. > I suppose this infrastructure can be used to implement the idea in > https://www.postgresql.org/message-id/CAMsr+YHii-BCC7ddpbb8fpCgzt0wMRt5GYZ0W_kD_Ft8rwWPiQ@mail.gmail.com > in some more acceptable manner. I'm not proposing it for now, just > parking the idea for a future patch. Ah, I thought I remembered the callback idea from some previous discussion, but I'd not located this one. I think I've got a nicer API for the per-context-type stats functions than what Craig proposes there, but we could imagine doing this API or something close to it for MemoryContextStatsInternal. Or, as I mentioned before, an external caller could just implement the scan over the context tree for itself, and format the data however it wants. regards, tom lane
Commits
-
Add memory context identifier to portal context
- 94c1f9ba11d1 11.0 landed
-
Rename MemoryContextCopySetIdentifier() for clarity
- bbca77623fb5 11.0 landed
-
Allow memory contexts to have both fixed and variable ident strings.
- 442accc3fe0c 11.0 landed
-
Rethink MemoryContext creation to improve performance.
- 9fa6f00b1308 11.0 cited