<br><br><div class="gmail_quote">On Fri, Jul 27, 2012 at 11:16 AM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@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">Ah OK, I was not concentrated enough when I read Eliot post :)<br>
<br>
Eliot, this is not a bug, and normal code would statistically create<br>
other objects in between...<br>
But isn&#39;t there a risk  that tools like Fuel populate a small<br>
collection of simple objects (say an IdentitySet of Symbol), sharing<br>
same identityHash for each pair?<br>
It would noticeably increase the number of collisions well before the 4096 wall.<br></blockquote><div><br></div><div>Yes, but in practice no one&#39;s complained.  ANyway, look at both of these:</div><div><br></div><div>
Array new: 512 streamContents: [ :stream |</div><div>        1 to: 4096 do: [ :e | stream nextPut: Object new identityHash ] ] &quot;repeats every two objects&quot;</div><div><br></div><div>Array new: 512 streamContents: [ :stream |</div>
<div>        1 to: 4096 do: [ :e | stream nextPut: Array new identityHash ] ] &quot;repeats every 4 objects&quot;</div><div><br></div><div>I&#39;ll change the scaling so that the last one does not repeat.  So lets leave the test unchanged and put up with the failures until new VMs are in use.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Nicolas<br>
<br>
2012/7/27 Bert Freudenberg &lt;<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>&gt;:<br>
<div class="HOEnZb"><div class="h5">&gt;<br>
&gt; On 27.07.2012, at 05:18, Nicolas Cellier wrote:<br>
&gt;<br>
&gt;&gt; 2012/7/27 Frank Shearar &lt;<a href="mailto:frank.shearar@gmail.com">frank.shearar@gmail.com</a>&gt;:<br>
&gt;&gt;&gt; On 26 July 2012 22:35, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On Thu, Jul 26, 2012 at 3:59 AM, Levente Uzonyi &lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; On Thu, 26 Jul 2012, Frank Shearar wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; In a freshly updated trunk we have 3184 out of 3157 tests passing. We<br>
&gt;&gt;&gt;&gt;&gt;&gt; have 16 expected failures, and 11 failures, the latter being:<br>
&gt;&gt;&gt;&gt;&gt;&gt; * BecomeTest&gt;&gt;#testBecomeIdentityHash<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; This is failing due to a VM bug. There&#39;s a fix for it somewhere, but it<br>
&gt;&gt;&gt;&gt;&gt; seems like it&#39;s not integrated into Cog yet. Explore this to see that two<br>
&gt;&gt;&gt;&gt;&gt; consecutive objects share the same identityHash:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Array new: 10 streamContents: [ :stream |<br>
&gt;&gt;&gt;&gt;&gt;        1 to: 10 do: [ :e | stream nextPut: Object new identityHash ] ]<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; IMO this isn&#39;t a bug.  The identity hash changes at least every other<br>
&gt;&gt;&gt;&gt; object.  Hashes don&#39;t have to be unique.  But they do have to be<br>
&gt;&gt;&gt;&gt; well-distributed.  With 12 bits of identityHash Cog does fine basing its<br>
&gt;&gt;&gt;&gt; identityHash on the allocation pointer.  The above will wrap around after<br>
&gt;&gt;&gt;&gt; 8192 allocations, and provide 4096 distinct hashes (the maximum available).<br>
&gt;&gt;&gt;&gt; So the test needs rewriting to be more statistical.  The rationale for this<br>
&gt;&gt;&gt;&gt; is to speed up allocation.  Instead of a read-modify-write cycle to turn the<br>
&gt;&gt;&gt;&gt; crank of a pseudo-random generator there&#39;s a masking of the allocation<br>
&gt;&gt;&gt;&gt; pointer, which has to be read anyway to allocate an object.  BTW, the<br>
&gt;&gt;&gt;&gt; *right* way to implement this is to lazily allocate hashes, but for that<br>
&gt;&gt;&gt;&gt; there needs to be a flag (e.g. an identityHash of 0) to mark an object as<br>
&gt;&gt;&gt;&gt; not yet having a hash but existing Squeak images (because of the old<br>
&gt;&gt;&gt;&gt; definition) use 0 as a valid hash, so lazy hashes requires either a header<br>
&gt;&gt;&gt;&gt; bit (not enough of those) or an image change (which is my plan, as part of<br>
&gt;&gt;&gt;&gt; the new object representation).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; If it&#39;s not a bug, let&#39;s nuke the test. We need to get to a position<br>
&gt;&gt;&gt; where we have a green light.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; frank<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; If I understood Eliot correctly, it would suffice to keep a pointer<br>
&gt;&gt; alive to the created objects...<br>
&gt;&gt;<br>
&gt;&gt; preserveObjectsFromGarbageCollection := IdentitySet new.<br>
&gt;&gt; Array new: 10 streamContents: [ :stream |<br>
&gt;&gt;         1 to: 10 do: [ :e | stream nextPut:<br>
&gt;&gt; (preserveObjectsFromGarbageCollection add: Object new) identityHash ]<br>
&gt;&gt; ]<br>
&gt;&gt;<br>
&gt;&gt; Nicolas<br>
&gt;<br>
&gt;<br>
&gt; Makes no difference. GC does not happen after each allocation. Here&#39;s one that would work with Cog because each allocation is larger:<br>
&gt;<br>
&gt; (1 to: 10) collect: [ :e | (Array new: 4) identityHash ]<br>
&gt;<br>
&gt; But as Eliot said the test is somewhat meaningless in its current form.<br>
&gt;<br>
&gt; - Bert -<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>