[erlang-questions] Why erlang's computing performance is enormously less than c++

Tony Rogvall tony@REDACTED
Sat Nov 12 12:15:28 CET 2016


Thank you for the pointers and some insights.
I noticed that unroll directive was needed for this case. Actually size, effort and unroll was needed to get the desired effect.
I have been nagging about this before. Some effort should be made to do these optimizations automatically, they can be really hard to do manually, also consider how "funny" the code would look if you unroll the code your self ;-)

/Tony
"typed while walking!"

> On 12 Nov 2016, at 10:53, Richard Carlsson <carlsson.richard@REDACTED> wrote:
> 
> New as of 2001 or so. :-) Inlining is documented towards the bottom of this page: http://erlang.org/doc/man/compile.html
> 
> However, it only describes the inline_size option. There is also the inline_effort limit, which can be increased from the default 150 at the expense of compile time (its purpose is to ensure that the automatic inliner does not get bogged down in any particular part of the code). And then there's the slightly experimental inline_unroll, which is actually more of a side effect of the normal inlining behaviour if you just allow it to repeat itself on loops.
> 
> The interaction between the unroll limit and the size/effort limit is not obvious (and could maybe be improved - I haven't looked at that code for 15 years). In particular, the size limit seems to need bumping from the default 24 to about 200 or more for unrolling to happen, depending on the size of the loop body, and the effort limit also needs raising to at least 500 or 1000. I suggest you use the 'to_core' option and inspect the result until you find settings that work for your program. If you want to use unrolling you should probably put that code in a separate module and use custom compiler option for that module, not apply the same limits to your whole code base.
> 
> See comments in https://github.com/erlang/otp/blob/maint/lib/compiler/src/cerl_inline.erl for details. (It's a wonderful algorithm, if you're into that sort of thing, but can take a while to get your head around. It's basically just constant propagation and folding, treating functions like any other constants, and handling local functions and funs in the same way. I'd revisit it if I had the time.)
> 
> Note that if you use the option {inline,[{Name,Arity},...]} instead of just 'inline', then an older, simpler inliner is used, which _only_ inlines those functions you listed, ignoring any size limits.
> 
>         /Richard
> 
> 2016-11-12 6:56 GMT+01:00 Sergej Jurečko <sergej.jurecko@REDACTED>:
>> On Nov 11, 2016 6:40 PM, "Tony Rogvall" <tony@REDACTED> wrote:
>> 
>> > I used this ( WARNING! not to be used in production code yet, I guess? )
>> 
>> Are these flags new?
>> 
>> Sergej
>> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161112/9f3e1aa4/attachment.htm>


More information about the erlang-questions mailing list