On Sun, Sep 18, 2011 at 5:40 PM, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
I'm not quite sure it is correct.
The problem is if another Process want to use this MethodDictionary
while it is in an inconsistent state...
Or if you are rehashing on of the MethodDictionary which contains one
of the methods used by the rehashing itself.

Interesting. Thanks Nicolas for the pointer.
See recent changes from Levente in trunk.


heheheheh it seems Levente is still reading the Pharo mailing list.
So...I took his commits of today, and I have made a Pharo change set.
I have put all the information here: http://code.google.com/p/pharo/issues/detail?id=4826

Basically, he used #copyFrom: which is primitive and hence it avoids the inconsistent state.

If someone can check the changeset and give the OK, we can integrate it.

Thanks a lot
Nicolas

2011/9/17 Mariano Martinez Peck <marianopeck@gmail.com>:
>
>
> On Sat, Sep 17, 2011 at 10:26 PM, Nicolas Cellier
> <nicolas.cellier.aka.nice@gmail.com> wrote:
>>
>> 2011/9/17 Mariano Martinez Peck <marianopeck@gmail.com>:
>> > Hi guys. I was checking MethodDictionary >> rehash and this is terribly
>> > slow
>> > because of the #become. Then I saw #rehashWithoutBecome� but it answers
>> > a
>> > different instance. I need a #rehash that does the rehash in the real
>> > object
>> > and answers self. So...I need the regular #rehash but I want to avoid
>> > the
>> > #become. Is that possible somehow?
>> >
>> > This is the current implementation:
>> >
>> > 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
>> >
>> > I am terrible bad with Collection and friends, but cannot we do
>> > soemthing
>> > like this:
>> >
>> > 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) ] ].
>> >
>> > ��� 1 to: newInstance basicSize do: [ :index |
>> > ��� ��� (newInstance basicAt: index) ifNotNil: [ :key |
>> > ��� ��� ��� self at: key put: (newInstance array at: index) ] ].
>> >
>> > ��� ^ self
>> >
>>
>> I guess you should at least also copy the nil entries...
>> Maybe something like
>>
>> 1 to: newInstance basicSize do: [ :index |
>> � � � � self basicAt: index put: (newInstance basicAt: index).
>> � � � � array at: index put: (newInstance array at: index)].
>>
>
>
> Good point. So....I was not that mistaken ;)
> I have just replaced CompiledMethod >> hash� with this new method and at
> least all the tests in MethodDictionaryTest are green.
> Do you think this implementation is correct or there can be problems?
> because it is really MUCH faster than the original one.
>
> Thanks in advance
>
>>
>> >
>> > Thanks for any help.
>> >
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> >
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>




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