Re: Make MemoryContextMemAllocated() more precise

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Make MemoryContextMemAllocated() more precise
Date: 2020-04-07 12:14:16
Message-ID: CAApHDvqGJ6=ywHDZLaYeQMrN4W388COvEaKLQzHnY+v=YQ6Tmw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 7 Apr 2020 at 14:26, Jeff Davis <pgsql(at)j-davis(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2020-04-07 12:15:03 Re: Improving connection scalability: GetSnapshotData()
Previous Message Anna Akenteva 2020-04-07 12:07:42 Re: [HACKERS] make async slave to wait for lsn to be replayed