BTW, to understand how much important it is, without the apply the patch and iteration of 1000000 take around 1 second.1000000, at most divided by 3, mean that you are working with 333333 persistent classes.
2009/2/7 Fabio Maulo <[email protected]> > The problem is the boxing in GetHashCode method of the enumerator. > > > 2009/2/6 Roger Kratz <[email protected]> > >> Yes, it's put on the JIRA. There's a impl of >> IEqualityComparer<EntityMode> and "hard coded" in the constructor for the >> LinkedHashMap in EntityModeToTuplizerMapping. That's why a factory might be >> better (both used for dictionary and linkedhashmap and (?) some other >> IDictionary impl)? >> >> >> >> *From:* [email protected] [mailto: >> [email protected]] *On Behalf Of *Fabio Maulo >> *Sent:* den 6 februari 2009 16:57 >> >> *To:* [email protected] >> *Subject:* [nhibernate-development] Re: IDictionary<entitymode, xxx> >> >> >> >> Roger, >> >> BTW the EntityModeEqualityComparer as separated class is need (when we >> must use some other implementation of IDictionary). >> >> 2009/2/6 Roger Kratz <[email protected]> >> >> ...or... >> >> New EntityModeDic<tvalue>() >> >> ...or... >> >> EntityMode.CreateDic<tvalue() >> >> …or… >> >> ?? >> >> >> >> >> >> *From:* [email protected] [mailto: >> [email protected]] *On Behalf Of *Fabio Maulo >> *Sent:* den 6 februari 2009 16:51 >> >> >> *To:* [email protected] >> *Subject:* [nhibernate-development] Re: IDictionary<entitymode, xxx> >> >> >> >> Well... this is "our" work around; the real issue should be send to >> Microsoft. >> >> I hope Microsoft solve it soon; the hope is the last to die ;) >> >> >> >> In NH we have few IDictionary<K,V> depending on enum and probably all are >> using EntityMode as K so, probably, an implementation >> of EntityModeEqualityComparer and a simple modification to the Dictionary >> constructor call is enough. >> >> 2009/2/6 Roger Kratz <[email protected]> >> >> It's been added to the JIRA. >> >> >> >> However – if you think this should be handled in more places in the code, >> I guess it could be more generic than this "isolated" patch. >> >> >> >> *From:* [email protected] [mailto: >> [email protected]] *On Behalf Of *Fabio Maulo >> *Sent:* den 6 februari 2009 16:34 >> >> >> *To:* [email protected] >> *Subject:* [nhibernate-development] Re: IDictionary<entitymode, xxx> >> >> >> >> 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 >> >> >> >> >> -- >> Fabio Maulo >> >> >> >> >> -- >> Fabio Maulo >> > > > > -- > Fabio Maulo > -- Fabio Maulo
