[Glass] IdentityKeyValueDictionary vs IdentityDictionary?

Paul Baumann via Glass glass at lists.gemtalksystems.com
Fri Mar 10 09:00:36 PST 2017


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" <
glass at lists.gemtalksystems.com> 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,





-- 
Mariano
http://marianopeck.wordpress.com

_______________________________________________
Glass mailing list
Glass at lists.gemtalksystems.com
http://lists.gemtalksystems.com/mailman/listinfo/glass
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20170310/7448e90f/attachment.html>


More information about the Glass mailing list