What are the constraints/limitations of compiling with "+native"?
Asked Answered
D

1

7

What are the limitations/constraints when compiling Erlang .erl source with the +native option compared with the usual "non native" compilation?

Related to: Erlang OTP release compiles with HiPE?

Dripdry answered 5/2, 2010 at 13:31 Comment(1)
Thanks, I was just wondering why having hipe didn't speed up my program. With +native it runs twice as fast.Milestone
W
11

The functionality for tracing, breakpoints and single stepping that the BEAM emulator provides are not available in native compiled code. There is also still a limitation that native code is not really unloaded from memory when you load newer versions of the same module. (This can be an issue if you have a long-running system where you keep upgrading modules or generate and compile modules dynamically.)

Furthermore, there is a small overhead when jumping between native code and emulated BEAM code, so you should avoid having that kind of mode switch in a tight loop where speed matters. Preferably compile all closely related modules to native, and if possible also the most important standard library modules.

Finally, although the native compiler is quite well tested, the probability of a compiler bug in HiPE is a bit higher than that of bugs in the BEAM emulator C code (though probably no higher than that of bugs in GCC), so you may run a greater risk of system segfaults. It's quite rare these days though.

In summary, the main place where native compilation is probably not recommended for now, is in stand-alone products (like a black-box server that you deliver to a customer), where stability, remote debuggability, and low memory usage are your main concern and computation speed is typically not.

Willetta answered 6/2, 2010 at 10:7 Comment(3)
" the main place where native compilation is probably not recommended for now, is in stand-alone products ": this seems to contrast with what @rvidring said in a related post though.Dripdry
Can't seem to find the post you are referring to. Pointer?Willetta
What have I said? :-) I can't seem to find it either.Laureen

© 2022 - 2024 — McMap. All rights reserved.