[Vm-dev] New primitive??? [WAS] Re: [Pharo-project] IdentitySet but using #hash rather than #identityHash ?

Eliot Miranda eliot.miranda at gmail.com
Fri Dec 16 20:06:41 UTC 2011


On Fri, Dec 16, 2011 at 11:55 AM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:

>
>
> "Preallocate objects, so we won't count gc time."
>> n := 1000000.
>> objects := Array new: n streamContents: [ :stream |
>>        n timesRepeat: [ stream nextPut: Object new ] ].
>>
>>
>> set := IdentitySet new: n.
>> Smalltalk garbageCollect.
>> [1 to: n do: [ :i | set add: (objects at: i) ] ] timeToRun. "4949"
>>
>> set := LargeIdentitySet new.
>> Smalltalk garbageCollect.
>> [1 to: n do: [ :i | set add: (objects at: i) ] ] timeToRun. "331"
>>
>> set := (PluggableSet new: n)
>>        hashBlock: [ :object | object identityHash * 4096 + object class
>> identityHash * 64 ]; "Change this to #basicIdentityHash in Pharo"
>>        equalBlock: [ :a :b | a == b ];
>>        yourself.
>> Smalltalk garbageCollect.
>> [1 to: n do: [ :i | set add: (objects at: i) ] ] timeToRun. "5511"
>>
>>
>> I also have a LargeIdentityDictionary, which is relatively fast, but not
>> as fast as LargeIdentitySet, because (for some unknown reason) we don't
>> have a primitive that could support it. If we had a primitive like
>> primitive 132 which would return the index of the element if found or 0 if
>> not, then we could have a really fast LargeIdentityDictionary.
>>
>>
> Eliot do you think we could provide such a primitive?
>

Levente, what's the specification?


>
> Thanks
>
>
>
>>
>> Levente
>>
>>
>>> Cheers,
>>> Henry
>>>
>>>
>>>
>>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
>


-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20111216/d481b5dc/attachment.htm


More information about the Vm-dev mailing list