[BUG][FIX][Slowdown] Add preference too slow (Symbol>>hashtoo
slow)
Yoshiki Ohshima
ohshima at is.titech.ac.jp
Thu Feb 22 04:01:39 UTC 2001
Hi,
> We discussed this, and propose to fix the problem a
> different way. MethodDictionary is a subclass of Dictionary
> instead of IdentityDictionary (which didn't exist when
> MethodDict was defined ;-). MethodDictionary overrides
> "scanFor:" to provide IdentityDictionary speed, but it
> inherits #keys from Dictionary and so produces a Set here
> instead of an IdentitySet. Our proposal is to move
> methodDictionary to being a subclass of IdentityDictionary.
> Hopefully this will fix the problem in a more general way.
Your fix solves the particlar MethodDictionary case, but
still there are other many Dictionaries that uses Symbols as
keys. I think their speed would be also important.
I checked several expressions in my 3.0 final image.
--
Dictionary allInstances size.
=> 522
Dictionary allInstances inject: 0 into: [:sub :next | sub + next size].
=> 4900
"The total number of elements in all Dictionaries. Not too many."
(Dictionary allInstances select: [:d | d isEmpty not]) size.
=> 420
"So, roughly 80% of Dictionaries have at least one element."
keyClasses _ (Dictionary allInstances select: [:d | d isEmpty not]) collect: [:d | d keys someElement class].
"keyClasses is a collection of the keys' class."
keyClasses size.
=> 420
"same as the third expression."
(keyClasses select: [:c | c = Symbol]) size
=> 293
"This means 69% of the non-empty Dictionary uses Symbols as its key"
(keyClasses select: [:c | c = String]) size
=> 114
"This means 27% of the non-empty Dictionary uses Strings as its key"
[Dictionary allInstances do: [:d | d rehash]] timeToRun
=> ...
"seems take forever!"
--
... Umm, I was about to write "so let's use faster
implementation of Symbol>>hash!" I still think so, but
because those "Symbol-key Dictionaries" typically used for
classPools, converting the classPools to
IdentityDictionaries seems a good thing anyway.
-- Yoshiki
More information about the Squeak-dev
mailing list
|