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

From Jeff Davis
Subject Re: Make MemoryContextMemAllocated() more precise
Date
Msg-id 2253a0d148c4768016629f056141db94cdb80ca1.camel@j-davis.com
Whole thread Raw
In response to Make MemoryContextMemAllocated() more precise  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Make MemoryContextMemAllocated() more precise  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-hackers
On Mon, 2020-03-16 at 11:45 -0700, Jeff Davis wrote:
> Attached is a patch that makes mem_allocated a method (rather than a
> field) of MemoryContext, and allows each memory context type to track
> the memory its own way. They all do the same thing as before
> (increment/decrement a field), but AllocSet also subtracts out the
> free
> space in the current block. For Slab and Generation, we could do
> something similar, but it's not as much of a problem because there's
> no
> doubling of the allocation size.

Committed.

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.

We discussed a few other names, such as "space", "active memory", and
"touched". We didn't settle on any great name, but "touched" seemed to
be the most descriptive.

This refactoring/renaming can be done later; right now I committed this
to unblock disk-based Hash Aggregation, which is ready.

Regards,
    Jeff Davis





pgsql-hackers by date:

Previous
From: Chris Bandy
Date:
Subject: Re: [PATCH] Add schema and table names to partition error
Next
From: Bruce Momjian
Date:
Subject: Re: Define variables in the approprieate scope