Greg
Fri Aug 25 18:20:54 CDT 2006
Just threw this one at jd but I will mention it to you as well .. remember
that on a 32 bit platform that reference still costs you 4 bytes (8 on 64)
so on a 64 bit architecture it may very well cost you more to use this than
say a fixed char in a struct ... or an array of such and an in16 or int32
that you keep as an index.
Cheers,
Greg
"Chris Mullins" <cmullins@yahoo.com> wrote in message
news:%2372vcvJyGHA.4240@TK2MSFTNGP03.phx.gbl...
> Unfortunatly the performance is more important than my laziness - so I'll
> do it the hard way.
>
> Anything I can come up with, I'll add to my blog. I suspect, long term,
> other people would take this approach in high-performance systems if it
> were easier to do.
>
> --
> Chris
>
> "Greg Young" <druckdruckREMOVEgoose@hotmail.com> wrote
>>I should add that while this meets your laziness needs it may not work
>>really well for your performance needs.
>
>> "Greg Young" <druckdruckREMOVEgoose@hotmail.com> wrote in message
>> news:eBs87ZIyGHA.4104@TK2MSFTNGP02.phx.gbl...
>>>I would generate at runtime an "immutable proxy" ... this will obviously
>>>not help in all cases but atleast for getters/setters as you discuss ...
>>>You could also add something such as an [immutable] attribute so it could
>>>determine which methods were allowed to be called.
>>>
>>> Cheers,
>>>
>>> Greg Young
>>> MVP - C#
>>>
http://codebetter.com/blogs/gregyoung
>>>
>>> "Chris Mullins" <cmullins@yahoo.com> wrote in message
>>> news:u0QKOkHyGHA.5068@TK2MSFTNGP02.phx.gbl...
>>>> "David Browne" <davidbaxterbrowne no potted meat@hotmail.com> wrote:
>>>>>
>>>>> Why are trying to build an immutable wrapper around an existing type?
>>>>> If you want immutable type, why not just design it that way?
>>>>
>>>> Well, this is partly where the laziness comes in, and partly where the
>>>> real problem is more complex than the simple 1 class case I described.
>>>>
>>>> I have a number of classes to which I would like to do this, and I
>>>> would like to have Interning come along for the ride, so as to save me
>>>> quite a bit of memory.
>>>>
>>>> Our XMPP server ends up with lots and lots of these XmppId classes
>>>> stored all over the place, and the Interning will save us huge amounts
>>>> of memory. For example, a users roster is composed of (mostly) these
>>>> ID's, and users often have 10 to 100 other users in their roster.
>>>> Multiply this by 50k simultanious users online, and that's alot of
>>>> (mostly) duplicated XmppId classes.
>>>>
>>>> It also turns out that an XmppId class is really a composite class made
>>>> up of a Server ("coversant.net"), a User Name ("cmullins"), and a
>>>> resource, "work". Ideally each of these smaller classes to also be
>>>> immutable and Interned. This way all of the cases for:
>>>> user0001@coversant.net\work, user2, user3, user4 doesn't waste memory
>>>> on the server portion of the ID ('cause it's Interned).
>>>>
>>>> There are also combinations of these classes. For example BareXmppID is
>>>> a user@server with no resource, and is a class in it's own right, as
>>>> there is signifigant business logic around it.
>>>>
>>>> --
>>>> Chris Mullins
>>>>
>>>
>>>
>>
>>
>
>