IdentityKeyValueDictionary vs IdentityDictionary?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

IdentityKeyValueDictionary vs IdentityDictionary?

GLASS mailing list
Hi guys,

I was measuring performance of different dictionary classes for a given scenario and I still cannot understand the difference between IdentityDictionary and IdentityKeyValueDictionary.

For this particular case (where I was measure #at:put:) the later was much faster. Is that always the case? Because I normally use IdentityDictionary everywhere for identity based dictionaries.

Thanks in advance,



_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: IdentityKeyValueDictionary vs IdentityDictionary?

GLASS mailing list

Reading the class comments of the two classes and poking around in the implementation, it looks like IdentityKeyValueDictionary does not use associations when adding entries to the dictionary and IdentityDictionary creates associations ... so i seems that adding entries would always be more expensive for IdentityDictionary...

Dale


On 3/8/17 10:51 AM, Mariano Martinez Peck via Glass wrote:
Hi guys,

I was measuring performance of different dictionary classes for a given scenario and I still cannot understand the difference between IdentityDictionary and IdentityKeyValueDictionary.

For this particular case (where I was measure #at:put:) the later was much faster. Is that always the case? Because I normally use IdentityDictionary everywhere for identity based dictionaries.

Thanks in advance,




_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: IdentityKeyValueDictionary vs IdentityDictionary?

GLASS mailing list
In reply to this post by GLASS mailing list
The Association instances of IdentityDictionary make additions slower. There are usage patterns where ID can be faster and better. If used as a root collection that others share and update (existing keys) then ID would have less chance of commit conflict (sometimes only same-key modifications would conflict). IKVD is faster for collections that are mostly added to by one session. 

Page costs can be another performance difference (and tuning opportunity). IKVD would use fewer pages and keys and values would (by default) tend to be co-located. You could cluster keys structures separate from values structures to favor some access patterns. With ID you'd be able to cluster-tune with association instances but key-value pair references would always be co-located. Consider that a rehash of a collection can keep the same Association instances and so it is possible to cluster-tune ID associations for fewer page changes upon regrowth.

IKVD is not always faster and initial performance gains can have hidden every-day usage costs later. Know where each can better.

Whenever practical use #new: to create pre-grown collection instances. GS grows indexable collections exceptionally quickly, and so some collections will use #new anyway. [Advanced tip] You can modify #new: of one of the collections (I forget which, but likely a subclass of SequenceableCollection) to get much better performance by actually pregrowing. 

Another advanced tip is that using #size: to 0 improves GC performance when you know you no longer need a collection. Unfortunately not all the GS collections do the most efficient resize to empty. I found big improvements by implementing something named like #resizeEmpty to do the most efficient (and polymorphic) assistive cleanup.

Paul Baumann


On Mar 8, 2017 1:51 PM, "Mariano Martinez Peck via Glass" <[hidden email]> wrote:
Hi guys,

I was measuring performance of different dictionary classes for a given scenario and I still cannot understand the difference between IdentityDictionary and IdentityKeyValueDictionary.

For this particular case (where I was measure #at:put:) the later was much faster. Is that always the case? Because I normally use IdentityDictionary everywhere for identity based dictionaries.

Thanks in advance,



_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass



_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass