<div dir="ltr">Just a side note: there are not only big-endian platforms, but big-endian protocols also for data exchange...<br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-09-01 4:12 GMT+02:00 Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi Andres,<br>
<span class=""><br>
&gt; On Aug 31, 2015, at 5:52 PM, Andres Valloud &lt;<a href="mailto:avalloud@smalltalk.comcastbiz.net">avalloud@smalltalk.comcastbiz.net</a>&gt; wrote:<br>
&gt;<br>
&gt; FWIW... IMO it&#39;s better to enable access to the relevant compiler intrinsic with platform specific macros, rather than implementing instructions such as Intel&#39;s BSWAP or MOVBE by hand.  In HPS, isolating endianness concerns from the large integer arithmetic primitives with such macros enabled 25-40% faster performance on big endian platforms. Just as importantly, the intrinsic approach takes significantly less code to implement.<br>
<br>
</span>Makes sense, and the performance increases are impressive.  The only issue I have is that the Cog JIT (which would have the easiest time generating those intrinsics) currently runs only in little-endianness platforms and I seriously doubt it will run in a big endianness platform in the next five years.  PowerPC is the only possibility I see.  Yes, ARM is biendian but all the popular applications I know of are little endian.<br>
<br>
VW&#39;s a different beast; significant big endian legacy.<br>
<br>
But what you say about isolating makes perfect sense.  Thanks<br>
<div class="HOEnZb"><div class="h5"><br>
&gt;<br>
&gt;&gt; On 8/31/15 10:25 , Eliot Miranda wrote:<br>
&gt;&gt; Hi Chrises,<br>
&gt;&gt;<br>
&gt;&gt;     my vote would be to write these as 12 numbered primitives, (2,4 &amp; 8<br>
&gt;&gt; bytes) * (at: &amp; at:put:) * (big &amp; little endian) because they can be<br>
&gt;&gt; performance critical and implementing them like this means the maximum<br>
&gt;&gt; efficiency in both 32-bit and 64-bit Spur, plus the possibility of the<br>
&gt;&gt; JIT implementing the primitives.<br>
&gt;&gt;<br>
&gt;&gt; On Sun, Aug 30, 2015 at 10:01 PM, Chris Cunningham<br>
&gt;&gt; &lt;<a href="mailto:cunningham.cb@gmail.com">cunningham.cb@gmail.com</a> &lt;mailto:<a href="mailto:cunningham.cb@gmail.com">cunningham.cb@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;    Hi Chris,<br>
&gt;&gt;<br>
&gt;&gt;    I&#39;m all for having the fastest that in the image that works.  If you<br>
&gt;&gt;    could make your version handle endianess, then I&#39;m all for including<br>
&gt;&gt;    it (at least in the 3 variants that are faster).  My first use for<br>
&gt;&gt;    this (interface for KAFKA) apparently requires bigEndianess, so I<br>
&gt;&gt;    really want that supported.<br>
&gt;&gt;<br>
&gt;&gt;    It might be best to keep my naming, though - it follows the name<br>
&gt;&gt;    pattern that is already in the class.  Or will yours also support 128?<br>
&gt;&gt;<br>
&gt;&gt;    -cbc<br>
&gt;&gt;<br>
&gt;&gt;    On Sun, Aug 30, 2015 at 2:38 PM, Chris Muller &lt;<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a><br>
&gt;&gt;    &lt;mailto:<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;        Hi Chris, I think these methods belong in the image with the fastest<br>
&gt;&gt;        implementation we can do.<br>
&gt;&gt;<br>
&gt;&gt;        I implemented 64-bit unsigned access for Ma Serializer back in 2005.<br>
&gt;&gt;        I modeled my implementation after Andreas&#39; original approach which<br>
&gt;&gt;        tries to avoid LI arithmetic.  I was curious whether your<br>
&gt;&gt;        implementations would be faster, because if they are then it could<br>
&gt;&gt;        benefit Magma.  After loading &quot;Ma Serializer&quot; 1.5 (or head) into a<br>
&gt;&gt;        trunk image, I used the following script to take comparison<br>
&gt;&gt;        measurements:<br>
&gt;&gt;<br>
&gt;&gt;        | smallN largeN maBa cbBa |  smallN := ((2 raisedTo: 13) to: (2<br>
&gt;&gt;        raisedTo: 14)) atRandom.<br>
&gt;&gt;        largeN := ((2 raisedTo: 63) to: (2 raisedTo: 64)) atRandom.<br>
&gt;&gt;        maBa := ByteArray new: 8.<br>
&gt;&gt;        cbBa := ByteArray new: 8.<br>
&gt;&gt;        maBa maUint: 64 at: 0 put: largeN.<br>
&gt;&gt;        cbBa unsignedLong64At: 1 put: largeN bigEndian: false.<br>
&gt;&gt;        self assert: (cbBa maUnsigned64At: 1) = (maBa unsignedLong64At: 1<br>
&gt;&gt;        bigEndian: false).<br>
&gt;&gt;        { &#39;cbc smallN write&#39; -&gt; [ cbBa unsignedLong64At: 1 put: smallN<br>
&gt;&gt;        bigEndian: false] bench.<br>
&gt;&gt;        &#39;ma smallN write&#39; -&gt; [cbBa maUint: 64 at: 0 put: smallN ] bench.<br>
&gt;&gt;        &#39;cbc smallN access&#39; -&gt; [ cbBa unsignedLong64At: 1 bigEndian:<br>
&gt;&gt;        false. ] bench.<br>
&gt;&gt;        &#39;ma smallN access&#39; -&gt; [ cbBa maUnsigned64At: 1] bench.<br>
&gt;&gt;        &#39;cbc largeN write&#39; -&gt; [ cbBa unsignedLong64At: 1 put: largeN<br>
&gt;&gt;        bigEndian: false] bench.<br>
&gt;&gt;        &#39;ma largeN write&#39; -&gt; [cbBa maUint: 64 at: 0 put: largeN ] bench.<br>
&gt;&gt;        &#39;cbc largeN access&#39; -&gt; [ cbBa unsignedLong64At: 1 bigEndian:<br>
&gt;&gt;        false ] bench.<br>
&gt;&gt;        &#39;ma largeN access&#39; -&gt; [ cbBa maUnsigned64At: 1] bench.<br>
&gt;&gt;          }<br>
&gt;&gt;<br>
&gt;&gt;        Here are the results:<br>
&gt;&gt;<br>
&gt;&gt;        &#39;cbc smallN write&#39;-&gt;&#39;3,110,000 per second.  322 nanoseconds per<br>
&gt;&gt;        run.&#39; .<br>
&gt;&gt;        &#39;ma smallN write&#39;-&gt;&#39;4,770,000 per second.  210 nanoseconds per<br>
&gt;&gt;        run.&#39; .<br>
&gt;&gt;        &#39;cbc smallN access&#39;-&gt;&#39;4,300,000 per second.  233 nanoseconds per<br>
&gt;&gt;        run.&#39; .<br>
&gt;&gt;        &#39;ma smallN access&#39;-&gt;&#39;16,400,000 per second.  60.9 nanoseconds<br>
&gt;&gt;        per run.&#39; .<br>
&gt;&gt;        &#39;cbc largeN write&#39;-&gt;&#39;907,000 per second.  1.1 microseconds per<br>
&gt;&gt;        run.&#39; .<br>
&gt;&gt;        &#39;ma largeN write&#39;-&gt;&#39;6,620,000 per second.  151 nanoseconds per<br>
&gt;&gt;        run.&#39; .<br>
&gt;&gt;        &#39;cbc largeN access&#39;-&gt;&#39;1,900,000 per second.  527 nanoseconds per<br>
&gt;&gt;        run.&#39; .<br>
&gt;&gt;        &#39;ma largeN access&#39;-&gt;&#39;1,020,000 per second.  982 nanoseconds per<br>
&gt;&gt;        run.&#39;<br>
&gt;&gt;<br>
&gt;&gt;        It looks like your 64-bit access is 86% faster for accessing the<br>
&gt;&gt;        high-end of the 64-bit range, but slower in the other 3 metrics.<br>
&gt;&gt;        Noticeably, it was only 14% as fast for writing the high-end of the<br>
&gt;&gt;        64-bit range, and similarly as much slower for small-number access..<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;        On Fri, Aug 28, 2015 at 6:01 PM, Chris Cunningham<br>
&gt;&gt;        &lt;<a href="mailto:cunningham.cb@gmail.com">cunningham.cb@gmail.com</a> &lt;mailto:<a href="mailto:cunningham.cb@gmail.com">cunningham.cb@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt;         &gt; Hi.<br>
&gt;&gt;         &gt;<br>
&gt;&gt;         &gt; I&#39;ve committed a change to the inbox with changes to allow<br>
&gt;&gt;        getting/putting<br>
&gt;&gt;         &gt; 64bit values to ByteArrays (similar to 32 and 16 bit<br>
&gt;&gt;        accessors).  Could this<br>
&gt;&gt;         &gt; be added to trunk?<br>
&gt;&gt;         &gt;<br>
&gt;&gt;         &gt; Also, first time I used the selective commit function - very<br>
&gt;&gt;        nice!  the<br>
&gt;&gt;         &gt; changes I didn&#39;t want committed didn&#39;t, in fact, get<br>
&gt;&gt;        commited.  Just the<br>
&gt;&gt;         &gt; desirable bits!<br>
&gt;&gt;         &gt;<br>
&gt;&gt;         &gt; -cbc<br>
&gt;&gt;         &gt;<br>
&gt;&gt;         &gt;<br>
&gt;&gt;         &gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; _,,,^..^,,,_<br>
&gt;&gt; best, Eliot<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
</div></div></blockquote></div><br></div>