Re: 9.5: Better memory accounting, towards memory-bounded HashAgg

From: Tomas Vondra <tv(at)fuzzy(dot)cz>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 9.5: Better memory accounting, towards memory-bounded HashAgg
Date: 2014-08-29 18:23:27
Message-ID: 5400C51F.40203@fuzzy.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 29.8.2014 16:12, Tom Lane wrote:
> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
>> I have a new approach to the patch which is to call a callback at each
>> block allocation and child contexts inherit the callback from their
>> parents. The callback could be defined to simply dereference and
>> increment its argument, which would mean block allocations anywhere in
>> the hierarchy are incrementing the same variable, avoiding the need to
>> traverse the hierarchy.
>
> Cute, but it's impossible to believe that a function call isn't going
> to be *even more* overhead than what you've got now. This could only
> measure out as a win when the feature is going unused.
>
> What about removing the callback per se and just keeping the argument,
> as it were. That is, a MemoryContext has a field of type "size_t *"
> that is normally NULL, but if set to non-NULL, then we increment the
> pointed-to value for pallocs and decrement for pfrees.

How is that going to work with two memory contexts (parent/child), both
requesting accounting? If I understand the proposal correctly, the child
will either inherit pointer to the field in parent (and then won't get
accounting for it's own memory), or wil get a private field (and thus
won't update the accounting of the parent context).

Or am I missing something?

regards
Tomas

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2014-08-29 18:32:05 Re: On partitioning
Previous Message Pavel Stehule 2014-08-29 18:20:44 Re: Built-in binning functions