Re: Double linking MemoryContext children

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: Jan Wieck <jan(at)wi3ck(dot)info>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Double linking MemoryContext children
Date: 2015-09-12 15:51:30
Message-ID: 15890.1442073090@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kevin Grittner <kgrittn(at)ymail(dot)com> writes:
> I guess the question is whether to add a pointer for each memory
> context to give the MemoryContextSetParent() function O(1)
> performance characteristics or add comments in front of this
> function to document how callers should organize their code to
> avoid O(N^2) performance. I generally prefer that callers of such
> a function need not be that aware of implementation details, so I
> would prefer the former.

On reflection, it's a bit silly to complain about one extra pointer per
MemoryContext, when the memory represented by the context is going to be
at least one kilobyte and usually a lot more. So I withdraw my objection
to the concept. I concur that we'd just as soon not worry about what
order things are done in.

> On the other hand, a grep indicates that there are two places that
> MemoryContextData.nextchild is set (and we therefore probably need
> to also set the new field), and Jan's proposed patch only changes
> one of them. If we do this, I think we need to change both places
> that are affected, so ResourceOwnerCreate() in resowner.c would
> need a line or two added.

Um. Sounds like it needs some actual code review then ...

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2015-09-12 18:27:52 Re: On-demand running query plans using auto_explain and signals
Previous Message Kevin Grittner 2015-09-12 15:35:59 Re: Double linking MemoryContext children