If the performance issue is caused by EqualityComparer I prefer the
implementation of a specific EqualityComparer instead other solution.

2009/2/6 Roger Kratz <[email protected]>

>  I can do a impl of the equalitycomparer and use that instead.
>
>
>
> Did a quick search in the source code and it seems to be other places where
> dics are keyed by entitymode. I'm not sure which of them are used heavily
> though, but I guess it wouldn't hurt to pass an IEqualityComparer to them
> all?
>
>
>
> Should I do this?
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Ayende Rahien
> *Sent:* den 6 februari 2009 16:01
>
> *To:* [email protected]
> *Subject:* [nhibernate-development] Re: IDictionary<entitymode, xxx>
>
>
>
> Duh!
> The implementation makes it obvious what is actually going on.
> I think that a better alternative than int keys would be to use a
> IEqualityComparer<TEnum> instead, that would keep the clarity, reduce
> casting and prevent boxing.
>
> On Fri, Feb 6, 2009 at 4:53 PM, Roger Kratz <[email protected]>
> wrote:
>
> That you'll better ask the dictionary implementors at Redmond J. I was a
> bit surprised by this myself some time ago. Just create a little test
> yourself and probably you will be more than surprised by the result…
>
>
>
> There are some articles out there describing it better than I probably can…
>
> http://www.safnet.com/writing/tech/archives/2007/07/performance_3_c.html
>
>
> http://blogs.msdn.com/shawnhar/archive/2007/07/02/twin-paths-to-garbage-collector-nirvana.aspx
>
> http://beardseye.blogspot.com/2007/08/nuts-enum-conundrum.html
>
>
>
>
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Ayende Rahien
> *Sent:* den 6 februari 2009 15:45
>
>
> *To:* [email protected]
> *Subject:* [nhibernate-development] Re: IDictionary<entitymode, xxx>
>
>
>
> Ha?
>
>
> Why would there be boxing involved at all?
>
> On Fri, Feb 6, 2009 at 3:46 PM, Roger <[email protected]> wrote:
>
>
> Hi
>
> EntityModeToTuplizerMapping holds a dic keyed by entitymode
> internally. From a perf perspective, it's a bad thing to do – enum as
> a key will cause a lot of boxing internally in dictionary operations.
> And in (large) resultsets these dictionary items in it will be
> retrieved _a lot_.
>
> I just made a quick test and changed this dictionary to be keyed by an
> int instead (casting the enum to int when added), some extreme queries
> (=fast query, big resultset) run approx 10% faster in total.
>
> I'll be glad to send this little patch. However, I would say a better
> solution would be to change this enum to a class instead (I don't
> really like enums at all :)). I can provide a patch for this as well,
> but this type has a lot of dependencies. In short words – before
> spending some hours doing this, I would like to see if you have any
> opinions on this?
>
> Whatever you think, I would strongly suggest that get rid of often
> used dictionaries keyed by enums.
>
> Keep up the great work!
>
> Regards
> Roger
>
>
>
>
>



-- 
Fabio Maulo

Reply via email to