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

Mariano Martinez Peck marianopeck at gmail.com
Fri Dec 16 19:55:40 UTC 2011


> "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?

Thanks



>
> Levente
>
>
>> Cheers,
>> Henry
>>
>>
>>
>


-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20111216/7a74eb11/attachment.htm


More information about the Vm-dev mailing list