Re: Make MemoryContextMemAllocated() more precise
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: pgsql-hackers@postgresql.org
Cc: Tomas Vondra <tomas.vondra@postgresql.org>, Andres Freund <andres@anarazel.de>
Date: 2020-03-28T00:21:10Z
Lists: pgsql-hackers
Attachments
- mcxt.patch (text/x-patch) patch
On Wed, 2020-03-18 at 15:41 -0700, Jeff Davis wrote:
> In an off-list discussion, Andres suggested that MemoryContextStats
> could be refactored to achieve this purpose, perhaps with flags to
> avoid walking through the blocks and freelists when those are not
> needed.
Attached refactoring patch. There's enough in here that warrants
discussion that I don't think this makes sense for v13 and I'm adding
it to the July commitfest.
I still think we should do something for v13, such as the originally-
proposed patch[1]. It's not critical, but it simply reports a better
number for memory consumption. Currently, the memory usage appears to
jump, often right past work mem (by a reasonable but noticable amount),
which could be confusing.
Regarding the attached patch (target v14):
* there's a new MemoryContextCount() that simply calculates the
statistics without printing anything, and returns a struct
- it supports flags to indicate which stats should be
calculated, so that some callers can avoid walking through
blocks/freelists
* it adds a new statistic for "new space" (i.e. untouched)
* it eliminates specialization of the memory context printing
- the only specialization was for generation.c to output the
number of chunks, which can be done easily enough for the
other types, too
Regards,
Jeff Davis
[1]
https://postgr.es/m/ec63d70b668818255486a83ffadc3aec492c1f57.camel%40j-davis.com
Commits
-
Create memory context for HashAgg with a reasonable maxBlockSize.
- 50a38f65177e 13.0 landed
-
Specialize MemoryContextMemAllocated().
- e00912e11a9e 13.0 landed