<br><br><div class="gmail_quote">On Wed, Jan 18, 2012 at 8:58 PM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com">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><br><div class="gmail_quote">On Wed, Jan 18, 2012 at 8:02 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@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><br><br><div class="gmail_quote"><div class="im">On Wed, Jan 18, 2012 at 2:25 AM, Henrik Johansen <span dir="ltr">&lt;<a href="mailto:henrik.s.johansen@veloxit.no" target="_blank">henrik.s.johansen@veloxit.no</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I really don&#39;t see what good could come of it being available in general…<br></blockquote><div><br></div></div><div>I can think of one good use, which my file tried to illustrate.  </div></div></blockquote></div></blockquote>
<div><br> I have another one but I am not sure if I can make it clear. In my case, I have original which I do #becomeForward: to proxies. Original objects are then swapped out to disk and garbage collected. Then after, I materialize from disk, and I do proxies  #becomeForward: materialized objects.  I have no idea whether original objects were stored in hashed collections. Not even in which collections. So...to avoid rehashing all instances of all hashed collections, what I do is the becomeForward: that copies identityHash.  Problem is...that when I do original objects becomeForward: proxies ... it change the identityHash of proxies, and what happens if proxies were stored also in hashed collections?  would need a rehash...<br>
<br>So...with this new primitive I can directly set the same identityHash to the proxy when I create it, since I know who he will proxify :)<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"><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>If Symbol instances identity hashes were derived from their string hash then they would be hashed the same in all images.  One can take advantage of this in e.g. method dictionary layout and hence binary class loading.  This happens in two steps.</div>


<div><br></div><div>With modern machines, where linear search through a dictionary is fast, and with a JIT with inline cacheing (and even an interpreter with a large method lookup cache), where method dictionaries are not looked at much, one can save a significant amount of space by making method dictionaries flat pair-wise arrays of selector, method.  Most method dictionaries are small and linear search is faster than fetching the Symbol&#39;s identity hash and doing a hash probe.  By ordering method dictionaries  by selector identityHash, very large method dictionaries such as Object&#39;s are indexed using binary search.  We saved about 8% of the image size in VisualWorks by moving to this representation (one saves on eliminating the nils in the selector vector and the value vector, and in eliminating the value vector/method array, hence saving its header space; you still need the space for the method).  [The savings in Squeak look to be much less; I just found that he same overhead in the 4.3 trunk image is only ~ 1.7%].</div>


<div><br></div><div>Now, if in addition selector identityHashes are deterministic, derived from their string hash, then one does not need to rehash/reorder a method dictionary when loading it from a binary stream (e.g. Fuel), which is again a win.</div>

</div></blockquote><div><br>Indeed, in Fuel we would save the rehash of MethodDictionaries.  <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><br></div><div>Now, I&#39;m not suggesting we do either of these things now, but making Symbol identity hashes deterministic, derived from their string hash, can enable significant optimisation further down the road.</div>
<div><div class="h5">

<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Henry<br>
<div><div></div><div><br>
On Jan 18, 2012, at 8:16 26AM, stephane ducasse wrote:<br>
<br>
&gt;<br>
&gt; After the discussions we got and with a really big comment I would add it.<br>
&gt;<br>
&gt; Stef<br>
&gt; On Jan 17, 2012, at 11:02 PM, Mariano Martinez Peck wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Tue, Jan 17, 2012 at 8:04 PM, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Tue, Jan 17, 2012 at 8:43 AM, Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi guys. Becuase of some work I am doing with proxies, I would like to be able to set a specific identityHash to a proxy instance. I can add this primitive in my VM, but I was thinking if this could be of a general interest also?<br>



&gt;&gt;<br>
&gt;&gt; It already exists.  See primitiveSetIdentityHash in InterpreterPrimitives.  Primitive # 161.<br>
&gt;&gt;<br>
&gt;&gt; Thank you so much Eliot. You even save my time of coding it ;)  I should have checked before...I always forget about InterpreterPrimitives hahaha<br>
&gt;&gt; So...Pharaoers... do you want the image side of the primitive and some tests?  I can provide that if desired (in my opinion I would include it)<br>
&gt;&gt;<br>
&gt;&gt; Cheers<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Cheers<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Mariano<br>
&gt;&gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; best,<br>
&gt;&gt; Eliot<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Mariano<br>
&gt;&gt; <a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
&gt;&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div></div></div><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br>best,<div>Eliot</div><br>
<br></font></span></blockquote></div><span class="HOEnZb"><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>