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

From David Rowley
Subject Re: Make MemoryContextMemAllocated() more precise
Date
Msg-id CAApHDvqGJ6=ywHDZLaYeQMrN4W388COvEaKLQzHnY+v=YQ6Tmw@mail.gmail.com
Whole thread Raw
In response to Re: Make MemoryContextMemAllocated() more precise  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-hackers
On Tue, 7 Apr 2020 at 14:26, Jeff Davis <pgsql@j-davis.com> wrote:
>
> On Mon, 2020-04-06 at 23:39 +1200, David Rowley wrote:
> > 4. Do you think it would be better to have two separate functions for
> > MemoryContextCount(), a recursive version and a non-recursive
> > version.
>
> I could, but right now the only caller passes recurse=true, so I'm not
> really eliminating any code in that path by specializing the functions.
> Are you thinking about performance or you just think it would be better
> to have two entry points?

I was thinking in terms of both performance by eliminating a branch,
but mostly it was down to ease of code reading.

I thought it was easier to read:
MemoryContextGetCountersRecruse(&counters); then
MemoryContextGetCounters(&counters, true); since I might need to go
see what "true" is for.

The non-recursive version, if we decide we need one, would likely just
be 1 one-line body function calling the implementation's getcounter
method.

David



pgsql-hackers by date:

Previous
From: Anna Akenteva
Date:
Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed
Next
From: Andres Freund
Date:
Subject: Re: Improving connection scalability: GetSnapshotData()