List:Internals« Previous MessageNext Message »
From:Monty Taylor Date:February 27 2009 7:17am
Subject:Re: [Drizzle-discuss] Removing Array custom vector allocation for
semi-join subqueries
View as plain text  
MARK CALLAGHAN wrote:
> On Thu, Feb 26, 2009 at 6:13 PM, Monty Taylor <mordred@stripped> wrote:
>> Brian Aker wrote:
>>> Hi!
>>>
>>> On Feb 26, 2009, at 12:21 PM, Mats Kindahl wrote:
>>>
>>>> recycling. In that case, any pointers into that old memory that are
> still
>>>> dangling would not be useful, since the memory is likely to be
>>>> overwritten with
>>> mem_root or not mem_root... I consider this to be pretty bad behavior to
>>> rely on.
>> Not mem_root. C++ has much better ways of dealing with this sort of
>> thing (automatic delloc when you're done with stuff) mem_root was likely
>> very important when it was written, and a great idea then.
>>
>> Now it's just extra complexity that hides behavior.
>>
>> Monty
> 
> My C++ skills have faded given what I work on. What does C++ have that
> is similar to mem_root? That is, I want an allocator to be used with a
> variety of STL classes for which I will deallocate everyting all at
> once but at some random point in the future. And since I don't want to
> have to retain handles to everything that has been allocated, I prefer
> to invoke deallocate on the allocator rather than all of the objects
> that have been allocated from it.

No. C++ does not have a thing that behaves exactly like mem_root does.
You could build one, but it would be (and is) a bad idea, because things
you're allocating in C++ are objects, and you need to run destructors on
them, and because then you'd be trying to program idiomatic C in C++.

I know that we have several among us who hate C++ with a passion. (hi
stewart) That's fine... I'm not fond of PHP myself. We all have
preferences. Early on the choice was made that Drizzle would be C++ and
not C, because mixing the two turns out to be a pretty bad idea (not
just from coding style, but because some C constructs mean different
things to a C++ compiler, and some assumptions that C people make aren't
right in C++ - and vice-versa.) . The choice could have gone the other
way - we could have picked C and started ripping out the C++ bits. But
we didn't.

Therefore, I'm going to say that what we _really_ want instead of
mem_root is what Jay and I have been pushing for for a while - resource
management through ownership. Pointers to allocated memory should be
contained in, owned by and managed by an object, such that when the
object goes away, so does the memory. It's almost like magic how much a
nice containment hierarchy can achieve the end-goal of mem_root.

I'd post a code sample... but I'm falling asleep sitting here... I'll
come back to this in the morning. :)

Monty
Thread
Removing Array custom vector allocation for semi-join subqueriesJay Pipes26 Feb
  • Re: Removing Array custom vector allocation for semi-join subqueriesKonstantin Osipov26 Feb
    • Re: Removing Array custom vector allocation for semi-join subqueriesJay Pipes26 Feb
  • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesKonstantin Osipov26 Feb
    • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesJay Pipes26 Feb
Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesBrian Aker26 Feb
  • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesMonty Taylor27 Feb
    • Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesMARK CALLAGHAN27 Feb
      • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesMonty Taylor27 Feb
        • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesKonstantin Osipov27 Feb
          • Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesMARK CALLAGHAN27 Feb
        • Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesMARK CALLAGHAN27 Feb
          • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesJim Starkey27 Feb
    • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesMichael Widenius2 Mar
      • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesJay Pipes2 Mar
      • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesJim Starkey2 Mar
        • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesKonstantin Osipov2 Mar
        • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesMichael Widenius5 Mar
Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesBrian Aker26 Feb