<br><br><div class="gmail_quote">On Fri, May 14, 2010 at 4:43 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@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><div></div><div class="h5">On 15 May 2010 02:35, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt; The cardinal rule of running benchmarks is to compare apples to apples.<br>
&gt;  You&#39;ve compared apples to oranges, i.e. an optimized reimplementation of<br>
&gt; WideString&gt;&gt;hash that eliminates the mapping of codes to characters, against<br>
&gt; the vanilla Squeak implementation.  You need to at least compare the NB<br>
&gt; implementation against<br>
&gt; WideString methods for comparison<br>
&gt; fastHash<br>
&gt; | stringSize hash low |<br>
&gt; stringSize := self size.<br>
&gt; hash := ByteString identityHash bitAnd: 16rFFFFFFF.<br>
&gt; 1 to: stringSize do: [:pos |<br>
&gt; hash := hash + (self wordAt: pos).<br>
&gt; &quot;Begin hashMultiply&quot;<br>
&gt; low := hash bitAnd: 16383.<br>
&gt; hash := (16r260D * low + ((16r260D * (hash bitShift: -14) + (16r0065 * low)<br>
&gt; bitAnd: 16383) * 16384)) bitAnd: 16r0FFFFFFF.<br>
&gt; ].<br>
&gt; ^ hash<br>
&gt; | s n |<br>
&gt; s := (WideString with: (Character value: 16r55E4)) , &#39;abcdefghijklmno&#39;.<br>
&gt; n := 100000.<br>
&gt; { [1 to: n do: [:i| s fastHash. s fastHash. s fastHash. s fastHash. s<br>
&gt; fastHash. s fastHash. s fastHash. s fastHash. s fastHash. s fastHash]]<br>
&gt; timeToRun.<br>
&gt;  [1 to: n do: [:i| s hash. s hash. s hash. s hash. s hash. s hash. s hash. s<br>
&gt; hash. s hash. s hash]] timeToRun. }<br>
&gt;      #(829 1254)<br>
&gt; ASo your measurements tell us nothing about a general comparison of NB<br>
&gt; against the Squeak VM or Cog.  They only demonstrate (unsurprisingly) that a<br>
&gt; loop summing integers in an array goes PDQ.  On the other hand my numbers<br>
&gt; showed Cog 10x faster than the Squeak interpreter when executing exactly the<br>
&gt; same bytecode.<br>
<br>
</div></div>Yes, of course you&#39;re right.<br>
But i didn&#39;t compared it with Cog, because i can&#39;t.<br>
And NB is not for translating bytecodes into native code,<br>
it is for authoring a primitives using native code.<br>
So, my comparison is how faster it could be , if implemented primitively.<br>
<br>
I can only imagine, how faster the whole thing would be if we<br>
cross-hatch NB and Cog,<br>
where Cog will serve as a smalltalk optimizer , and NB will serve for<br>
manual optimizations<br>
for heavy numerical crunching :)<br></blockquote><div><br></div><div>Yes, this is a very cool direction.   One effort should be AOStA/SIStA with Marcus, which will do adaptive optimization/speculative inlining a la Self &amp; Hotspot.  Being able to directly generate machine code with NB and not have to rely on the VM&#39;s naive code generator would allow machine-specific optimization ad excellent register usage.  This could beat C.  The difficulty here is in portability.  Another more researchy direction would be a Klein approach where the Cog code generator is eliminated and replaced by NB, perfectly possible since Cog retains the interpreter which can be fallen back upon at any time.  Again portability is an issue.</div>
<div><br></div><div>best,</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
&gt; best<br>
&gt; Eliot<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
</font><div><div></div><div class="h5">Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</div></div></blockquote></div><br>