[erlang-questions] Hipe and Binary - Bitstring
Kostis Sagonas
kostis@REDACTED
Wed Mar 27 21:30:09 CET 2019
On 3/27/19 1:04 PM, John Högberg wrote:
> Hi Oliver,
>
> I've tried to reproduce this discrepancy on my machine, but I can only
> see a modest difference on latest OTP 21 (the results are in microseconds):
>
> Erlang/OTP 21 [erts-10.3.1] [source] [64-bit] [smp:24:24] [ds:24:24:10] [async-threads:1] [hipe]
>
>
> Eshell V10.3.1 (abort with ^G)
>
> 1> c(t, []).
>
> {ok,t}
>
> 2> t:bench(one).
>
> 15957304
>
> 3> t:bench(union).
>
> 559470
>
> 4> c(t, [native]).
>
> {ok,t}
>
> 5> t:bench(one).
>
> 3611371
>
> 6> t:bench(union).
>
> 501871
>
>
> I've attached the source code I used for this test, am I missing something?
We are obviously missing the benchmark program that Oliver used to get
numbers. But the "400x faster" figure cannot possibly be right.
Personally, I cannot see how one could turn function union/2, which is a
one-liner with two bitstring matches and one construction, into a
benchmark. So, it's not surprising that the performance difference
there is very small.
On the other hand, I would not call the performance difference between
BEAM and HiPE that you observed "modest". Four times faster execution
is IMO something that deserves a better adjective.
Kostis
> On Wed, 2019-03-27 at 10:09 +0100, Oliver Bollmann wrote:
>>
>> I use, with binaries like <<1:1000000>>,
>>
>> one(F,<<Size:64/unsigned,Bitmap:Size/bitstring,_/bitstring>>) ->
>> one(F,Bitmap,0,[]).
>> one(F, <<0:1,R/bitstring>>,N,Acc) ->
>> one(F,R,N +1,Acc);
>> one(F, <<1:1,R/bitstring>>,N,Acc) ->
>> one(F,R,N +1, [F(N) |Acc]);
>> one(_, <<>>,_,Acc) ->Acc.
>> union(<<Size:64/unsigned,L:Size/unsigned,P/bitstring>>,
>> <<Size:64/unsigned,R:Size/unsigned,_/bitstring>>) ->
>> <<Size:64/unsigned, (L bor R):Size/unsigned,P/bitstring>>.
>>
>> and call this functions 1,000,000 times, this takes for 1,000 calls
>> about 20 minutes,
>>
>> if i compile with native -compile([native,{hipe, o2}])it takes 3
>> seconds for 1,000 calls, so it is about 400x faster !!
>>
>> OS: OSX
>>
>> What is the secret?
>>
>> --
>> Grüße
>> Oliver Bollmann
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list