So, is it safe to integrate? Guille On Sat, Aug 21, 2010 at 9:06 PM, Levente Uzonyi <leves@elte.hu> wrote:
On Sat, 21 Aug 2010, Guillermo Polito wrote:
Hi! I wass looking at tha issue, specially at the item that says:
"- ensure that #rehashWithoutBecome doesn't send #become:, making #rehashAllInstances a lot faster"
And the change made in squeak was:
Item was changed: ----- Method: MethodDictionary>>rehashWithoutBecome (in category 'private') ----- rehashWithoutBecome
+ Â Â Â | newInstance | + Â Â Â newInstance := self species new: self basicSize - 1. "Make sure it has the same capacity" + Â Â Â 1 to: self basicSize do: [ :index | + Â Â Â Â Â Â Â (self basicAt: index) ifNotNil: [ :key | + Â Â Â Â Â Â Â Â Â Â Â newInstance at: key put: (array at: index) ] ]. + Â Â Â ^newInstance! - Â Â Â | newSelf | - Â Â Â newSelf := self species new: self size. - Â Â Â 1 to: self basicSize do: [ :i | - Â Â Â Â Â Â Â | key | - Â Â Â Â Â Â Â (key := self basicAt: i) ifNotNil: [ - Â Â Â Â Â Â Â Â Â Â Â newSelf at: key put: (array at: i) ] ]. - Â Â Â ^newSelf!
And I figured out that this change does nothing with its comment "ensure that #rehashWithoutBecome doesn't send #become:"
Also, the only senders in the Core image are ScriptLoader SmalltalkImage (and there is no ?#rehashAllInstances ).
------------------------------------------
I tried this code before and after the change
oldDicts := MethodDictionary allInstances. [ | newDicts | Â newDicts := Array new: oldDicts size. Â Â Â Â oldDicts withIndexDo: [ :d :index | newDicts at: index put: d rehashWithoutBecome ].] timeToRun
And I saw a little improvement in performance (but it fluctuated a lot...).
Does anyone know a performance difference between size and basicSize in Dictionary, HashedCollection or MethodDictionary?
1. #basicSize is only meaningful for MethodDictionary, for other HashedCollections it's not related to the elements of the collection (at least in Squeak). 2. The performance difference (in Squeak) comes from the fact that if #size returns a power of two, then (with the old code) the MethodDictionary will grow when the last element is inserted by the loop. During the growth all elements will be hashed again and #become: will be used to swap the old and the new MethodDictionary, which is "very slow" in Squeak (and in Pharo).
So if you apply the change and you have a few MethodDictionaries with power of two size in your image and all relevant changes from Squeak are applied, then you should see the speedup.
All in all: in Squeak without this patch #rehashWithoutBecome could send #become: in the "background".
Levente
Thanks
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project