Re: Make MemoryContextMemAllocated() more precise - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: Make MemoryContextMemAllocated() more precise
Date
Msg-id a5c3592c784fd502e89bc136785b7fadad5158f8.camel@j-davis.com
Whole thread Raw
In response to Re: Make MemoryContextMemAllocated() more precise  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Make MemoryContextMemAllocated() more precise  (Andres Freund <andres@anarazel.de>)
Re: Make MemoryContextMemAllocated() more precise  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-hackers
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

Attachment

pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace onthe fly
Next
From: Tomas Vondra
Date:
Subject: Re: SLRU statistics