<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 16, 2015 at 11:49 AM, Chris Muller <span dir="ltr">&lt;<a href="mailto:asqueaker@gmail.com" target="_blank">asqueaker@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"><div class="HOEnZb"><div class="h5">&gt; In general the locality of the links are worse. In the example they are<br>
&gt; allocated almost next to each other.<br>
&gt; A slightly better example would be this:<br>
&gt;<br>
&gt; | buffer |<br>
&gt; buffer := Array new: 1000. &quot;This will hold the filler objects.&quot;<br>
&gt; #(1024 2048 4096 8192 16384 32768 65536) collect: [ :fillerSize |<br>
&gt;         | list |<br>
&gt;         list := LinkedList new.<br>
&gt;         1 to: 1000 do: [ :index |<br>
&gt;                 list add: (StackLink with: nil).<br>
&gt;                 buffer at: index put: (Array new: fillerSize) ].<br>
&gt;         Smalltalk garbageCollect.<br>
&gt;         fillerSize -&gt; [ list do: [ :ea | 1 + 2 ] ] bench ]<br>
&gt;<br>
&gt; { &quot;gap between nodes (x4 bytes)&quot; -&gt; &quot;runs&quot;<br>
&gt; 1024-&gt;&#39;78,000 per second.&#39;.<br>
&gt; 2048-&gt;&#39;78,600 per second.&#39;.<br>
&gt; 4096-&gt;&#39;77,500 per second.&#39;.<br>
&gt; 8192-&gt;&#39;73,300 per second.&#39;.<br>
&gt; 16384-&gt;&#39;70,200 per second.&#39;. 32768-&gt;&#39;66,400 per second.&#39;.<br>
&gt; 65536-&gt;&#39;56,400 per second.&#39;}<br>
&gt;<br>
&gt; (The result is &#39;45,700 per second.&#39; for Arrays)<br>
&gt;<br>
&gt; The results depend on the CPU (and probably on the OS too), but the numbers<br>
&gt; are still pretty good. Probably a longer list would cause more problem for<br>
&gt; the caches.<br>
&gt; The same for 10k elements in the list:<br>
&gt;<br>
&gt; {<br>
&gt; 1024-&gt;&#39;3,770 per second.&#39;.<br>
&gt; 2048-&gt;&#39;4,780 per second.&#39;.<br>
&gt; 4096-&gt;&#39;4,220 per second.&#39;.<br>
&gt; 8192-&gt;&#39;2,480 per second.&#39;.<br>
&gt; 16384-&gt;&#39;2,110 per second.&#39;}<br>
&gt;<br>
&gt; (The result is &#39;4,380 per second.&#39; for Arrays)<br>
&gt;<br>
&gt; So the speed of a list depends on the cache locality of its elements. The<br>
&gt; performance is still comparable with arrays for practical cases, but may be<br>
&gt; both faster and slower depending on the cache locality.<br>
<br>
</div></div>Geez you guys /seriously/ rock.  I never thought down to that level of<br>
(CPU) cache locality.<br>
<br>
You&#39;ve got me feeling like I should go back to some<br>
performance-critical code which is enumerating Array&#39;s and see about<br>
converting them to LinkedLists..  too bad I don&#39;t have time to do<br>
that!<br></blockquote><div><br></div><div>Please, folks, unless you&#39;re really pressed don&#39;t bother.  We should have Sista deployed this year and that will take care of this nicely. </div></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>