<br><br><div class="gmail_quote">On Thu, Apr 26, 2012 at 8:19 AM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 <br><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Hi Eliot/Levente. What is the status of this? Do we have already the new primitive? If true, how can we adapt LargeIdentitySet to use such new primitive?<br>
</blockquote>
<br></div></div>
AFAIK the new primitive is not implemented yet. Adding the primitive to the interpreter VM is very easy, but it seems to be a lot more complicated (to me) to add it to Cog, because the receiver can be a MethodContext which needs special handling.<br>



I&#39;ll rewrite both LargeIdentitySet and LargeIdentityDictionary when the primitive is ready.<span><font color="#888888"><br></font></span></blockquote><div><br>Thanks Levente. So we should wait Eliot.<br>
I will ping again in a couple of weeks/months  ;)<br><br></div></div></blockquote><div><br>Ping. So I did it :)<br>Eliot if you tell us what it is needed maybe I can push Esteban or Igor (or me?) to do it ;)<br></div></div>
</div></blockquote><div><br></div><div>Some form of accurate spec.  e.g. a simulation in Smalltalk, along with a specification of the types.  I&#39;m not happy about the receiver being a MethodContext because that means the primitive has to check argument types.  A primitive can assume the type of the receiver because the primitive can be put on a specific class in the hierarchy.  Hence  aBehavior adoptInstance: anObject is much better than anObject changeClassTo: aClass, because the former can know that the receiver is a valid behavior, and simply check that the argument is a suitable instance of the receiver, whereas the latter has to check both that aClass is a valid behavior (walking its hierarchy?  checking it has a valid methodDictionary, etc, etc) /and/ that the receiver is a suitable instance of the argument.  So if possible specify it as one or two primitives on LargeIdentitySet &amp; LargeIdentityDictionary.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><div><br>Thanks!<br>
<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<span><font color="#888888">
<br>
<br>
Levente</font></span><div><div><div><div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks!<br>
<br>
<br>
<br>
<br>
<br>
<br>
 <br>
<br>
      Levente<br>
<br>
<br>
            thanks<br>
<br>
            On Fri, Dec 16, 2011 at 3:28 PM, Levente Uzonyi &lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt; wrote:<br>
<br>
      On Fri, 16 Dec 2011, Henrik Sperre Johansen wrote:<br>
<br>
       On 16.12.2011 03:26, Levente Uzonyi wrote:<br>
<br>
<br>
            How about my numbers? :)<br>
<br>
            &quot;Preallocate objects, so we won&#39;t count gc time.&quot;<br>
            n := 1000000.<br>
            objects := Array new: n streamContents: [ :stream |<br>
              n timesRepeat: [ stream nextPut: Object new ] ].<br>
<br>
            set := IdentitySet new: n.<br>
            Smalltalk garbageCollect.<br>
            [1 to: n do: [ :i | set add: (objects at: i) ] ] timeToRun. &quot;4949&quot;<br>
<br>
            set := LargeIdentitySet new.<br>
            Smalltalk garbageCollect.<br>
            [1 to: n do: [ :i | set add: (objects at: i) ] ] timeToRun. &quot;331&quot;<br>
<br>
            set := (PluggableSet new: n)<br>
              hashBlock: [ :object | object identityHash * 4096 + object class<br>
            identityHash * 64 ]; &quot;Change this to #basicIdentityHash in Pharo&quot;<br>
              equalBlock: [ :a :b | a == b ];<br>
              yourself.<br>
            Smalltalk garbageCollect.<br>
            [1 to: n do: [ :i | set add: (objects at: i) ] ] timeToRun. &quot;5511&quot;<br>
<br>
<br>
            I also have a LargeIdentityDictionary, which is relatively fast, but not<br>
            as fast as LargeIdentitySet, because (for some unknown reason) we don&#39;t<br>
            have a primitive that could support it. If we had a primitive like<br>
            primitive 132 which would return the index of the element if found or 0 if<br>
            not, then we could have a really fast LargeIdentityDictionary.<br>
<br>
<br>
            Levente<br>
<br>
      Hehe yes, if writing a version fully exploiting the limited range, that&#39;s<br>
      probably the approach I would go for as well.<br>
(IAssuming it&#39;s the version at <a href="http://leves.web.elte.hu/**" target="_blank">http://leves.web.elte.hu/**</a><br>
squeak/LargeIdentitySet.st&lt;<a href="http://leves.web.elte.hu/squeak/LargeIdentitySet.st" target="_blank">htt<u></u>p://leves.web.elte.hu/squeak/<u></u>LargeIdentitySet.st</a>&gt;<br>
)<br>
<br>
Mariano commented in the version at <a href="http://www.squeaksource.com/**" target="_blank">http://www.squeaksource.com/**</a><br>
FuelExperiments &lt;<a href="http://www.squeaksource.com/FuelExperiments" target="_blank">http://www.squeaksource.com/<u></u>FuelExperiments</a>&gt; that it&#39;s<br>
slow for them, which I guess is due to not adopting #identityHash calls to<br>
#basicIdentityHash calls for Pharo:<br>
((0 to: 4095) collect: [:each | each &lt;&lt; 22 \\ 4096 ]) asSet size -&gt; 1<br>
So it basically uses 1 bucket instead of 4096... Whoops. :)<br>
<br>
Uploaded a new version to the MC repository which is adapted for Pharo,<br>
on the same machine my numbers were taken from, it does the same test as I<br>
used above in 871 ms. (181 with preallocation).<br>
<br>
<br>
Cool. One more thing: in Squeak the method using primitive 132 directly<br>
was renamed to #instVarsInclude:, so now #pointsTo: works as expected. If<br>
this was also added to Pharo, then the #pointsTo: sends should be changed<br>
to #instVarsInclude:, otherwise Array can be reported as included even if<br>
it wasn&#39;t added.<br>
I&#39;ll upload my LargeIdentityDictionary implementation to the same place<br>
this evening, since it&#39;s still 2-3 factor faster than other solutionts and<br>
there seem to be demand for it.<br>
<br>
<br>
Levente<br>
<br>
<br>
      Cheers,<br>
      Henry<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
Mariano<br>
<a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.<u></u>com</a><br>
<br>
<br>
<br>
<br>
<br>
--<br>
Mariano<br>
<a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.<u></u>com</a><br>
<br>
<br>
</blockquote>
</div></div></div></div></blockquote></div><span><font color="#888888"><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>
</div>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>