<br><br><div class="gmail_quote">On Wed, Jan 18, 2012 at 2:25 AM, Henrik Johansen <span dir="ltr">&lt;<a href="mailto:henrik.s.johansen@veloxit.no">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>I can think of one good use, which my file tried to illustrate.  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><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><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 class="h5"><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">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">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><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>