[squeak-dev] WideString hash is way slower than ByteString hash.

Eliot Miranda eliot.miranda at gmail.com
Fri May 14 19:48:56 UTC 2010


On Fri, May 14, 2010 at 10:28 AM, Levente Uzonyi <leves at elte.hu> wrote:

> On Fri, 14 May 2010, christophe.jalady at free.fr wrote:
>
>  Just print this two scripts:
>>
>> |s|
>> s := WideString with: (Character value: 16r55E4).
>> [100000 timesRepeat: [s hash]] timeToRun.
>>
>> |s|
>> s := ByteString with: (Character value: 16rE4) with: (Character value:
>> 16rE4)
>> with: (Character value: 16rE4) with: (Character value: 16rE4).
>> [100000 timesRepeat: [s hash]] timeToRun.
>>
>> I've seen that "ByteString>>stringHash:initialHash" use a primitive. Could
>> we
>> have such optimisation for WideString ?
>>
>
> Sure. There are (at least) four ways to do it:
> 1) Update the implementation of the primitive to support wordarrays. Then
> build a vm with it and finally change the image side code. This would be the
> best IMHO. Is there a reason why the primitive is not implemented this way?
> 2) Use NativeBoost to write a primitive for this method. This is much
> easier than building a vm/plugin, though you have to write the code in X86
> assembly. This would be a cool demo for NativeBoost's primitive writing
> capabilities. (Much better than the Fibonacci-number calculator. :))
> 3) Use Exupery, I think it can optimize methods like this.
> 4) Use the Cog VM. ;) (I wonder how fast this method is with Cog.)
>

2.66GHz Intel Core i7 MacBook Pro (my new tool!!!!).  Current Cog, my 3.8
derived work image:

|s|
s := WideString with: (Character value: 16r55E4).
[100000 timesRepeat: [s hash]] timeToRun. 16

|s|
s := ByteString with: (Character value: 16rE4) with: (Character value:
16rE4)
with: (Character value: 16rE4) with: (Character value: 16rE4).
[100000 timesRepeat: [s hash]] timeToRun. 10

|s|
s := WideString with: (Character value: 16r55E4).
[100000000 timesRepeat: [s hash]] timeToRun. 15725

|s|
s := ByteString with: (Character value: 16rE4) with: (Character value:
16rE4)
with: (Character value: 16rE4) with: (Character value: 16rE4).
[100000000 timesRepeat: [s hash]] timeToRun. 11078


Current 4.1/Squeak 4.1.1beta2U.app:
|s|
s := WideString with: (Character value: 16r55E4).
[100000 timesRepeat: [s hash]] timeToRun. 98

|s|
s := ByteString with: (Character value: 16rE4) with: (Character value:
16rE4)
with: (Character value: 16rE4) with: (Character value: 16rE4).
[100000 timesRepeat: [s hash]] timeToRun. 31

|s|
s := WideString with: (Character value: 16r55E4).
[100000000 timesRepeat: [s hash]] timeToRun. 100660

|s|
s := ByteString with: (Character value: 16rE4) with: (Character value:
16rE4)
with: (Character value: 16rE4) with: (Character value: 16rE4).
[100000000 timesRepeat: [s hash]] timeToRun. 29476

Current 4.1/current Cog
|s|
s := WideString with: (Character value: 16r55E4).
[100000 timesRepeat: [s hash]] timeToRun. 14

|s|
s := ByteString with: (Character value: 16rE4) with: (Character value:
16rE4)
with: (Character value: 16rE4) with: (Character value: 16rE4).
[100000 timesRepeat: [s hash]] timeToRun. 10

|s|
s := WideString with: (Character value: 16r55E4).
[100000000 timesRepeat: [s hash]] timeToRun. 14946

|s|
s := ByteString with: (Character value: 16rE4) with: (Character value:
16rE4)
with: (Character value: 16rE4) with: (Character value: 16rE4).
[100000000 timesRepeat: [s hash]] timeToRun. 10171

So quite a bit faster :)

best
Eliot


>
> Levente
>
>
>> Christophe.
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100514/54cfd7b3/attachment.htm


More information about the Squeak-dev mailing list