[erlang-questions] native

Kostis Sagonas <>
Tue Sep 11 16:22:11 CEST 2012


On 09/11/2012 09:06 AM, Tony Rogvall wrote:
>
> On 10 sep 2012, at 19:03, Thomas Lindgren <
> <mailto:>> wrote:
>
>>> ________________________________
>>> From: Kostis Sagonas < <mailto:>>
>>>
>>>
>>> I do not know why Thomas thinks that HiPE should be able to
>>> confortably beat BEAM on this sort of code (care to elaborate?). From
>>> a brief glance it seems to me that the code spends a lot of time in
>>> BIFs written in C (most notably list_to_tuple/1 and element/2, but
>>> also trunc/1, abs/1 and math:sin/1. All of these are outside the
>>> reach of the native code compiler.
>>
>>
>> The regular MD5 algorithm is basically a loop doing lots of integer
>> arithmetic and bit operations as well as accessing a few arrays. This
>> ought on the face of it to be quite amenable to native code
>> compilation. I'm amazed that the implementation Tony used managed to
>> get trunc/abs/sin into the inner loop, but that might as you say well
>> explain the problem.
>
> My goal with this implementation was not speed. I really wanted
> something simple to look at. erlang:md5 already exists, and
> there is no point competing with that. I just compiled it native for
> fun. So do not be amazed! :-)
> But as shown by kostis and others it looks like it is my computer that
> behaves badly, I will have a look.

I investigated this further.  Can it be that your computer runs in 
32-bit mode?  If so, I can explain what is happening.

Kostis



More information about the erlang-questions mailing list