Image using high CPU in WeakIdentityKeyDictionary>>scanFor:
chris at funkyobjects.org
Wed Sep 21 05:42:59 UTC 2005
> >>A TimeProfile while the system was doing nothing showed virtually all
> >>(99.4%) the time going to WeakIdentityDictionary>>scanFor:. This time
> >>is roughly evenly split between primitives and
Ross, I don't know if this is what you are experiencing but.. I noticed
WeakIdentityKeyDictionaries (and WeakValueDictionaries) have major performance
issues with #removeKey:, particularly with larger than 3k or so elements. I
think it has to do with the 12-bit identityHash which leads to many collisions.
I solved the (symptom of) the problem via "MaWeakIdentityKeyDictionary" which
simply wraps multiple WeakIdentityDictionaries as necessary to keep them each
under 3K elements or so. Believe it or not, this approach is 1000x faster with
removeKey: than the standard, and just a little slower on everything else.
Its just a temporary (almost three years now!) solution until identityHash can
be made better..
More information about the Squeak-dev