[Mono-dev] Dictionary`2: optimized and serialization-compatible with MS.net
js at hotfeet.ch
Fri Jun 8 09:36:01 EDT 2007
I've made the suggested changes and these are the results:
1) Do not store the hashcode: much slower (10-80%).
The Hashtable class stores the hashcode too...
Recalculating the hashcode on every access makes no sense.
2) Separate key and value arrays: no difference (with current GC).
If the separation will reduce the pressure on future GCs (sgen?),
then it makes a lot of sense.
3) 0 as 'no slot' value in table: slightly faster (2-7%).
The change is trivial (i.e. add 1 when storing a value in table,
subtract 1 when reading from it) and gives us a slight speed-up.
If it where up to me, I would do the changes 2 and 3.
What do you think (especially about change 2)?
On Wed, 2007-06-06 at 19:36 +0200, Paolo Molaro wrote:
> On 05/31/07 Juraj Skripsky wrote:
> > Index: System.Collections.Generic/Dictionary.cs
> > ===================================================================
> > --- System.Collections.Generic/Dictionary.cs (revision 78207)
> > +++ System.Collections.Generic/Dictionary.cs (working copy)
> The change looks fine overall.
> A few questions: did you have a measurable speedup by keeping the
> hashcode around (if you tested with that case)?
> Could you also experiment with separate key and value arrays
> (it would help a lot for the cases where one of the two is not a
> reference during GC)?
> It would also be nice to try a variation with a 0 NO_SLOT value, because
> it means you don't have to spend time initializing it (and it would mean
> starting allocations of slots at 1 or adding compensation code, though).
More information about the Mono-devel-list