Kevin Grittner <kgrittn@ymail.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