用“+本机”编译的约束/限制是什么? [英] What are the constraints/limitations of compiling with "+native"?

查看:123
本文介绍了用“+本机”编译的约束/限制是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 + native 选项编译Erlang .erl c'source时的限制/限制是什么? 非本机编译?



相关:> with with?????????????????????????that that that that that that that that that that that that that that that that that that that that that that that that that that that BEAM模拟器提供的本机编译代码不可用。当您加载相同模块的较新版本时,本地代码也不会从内存中真正卸载。 (如果您有一个长期运行的系统,您可以继续升级模块或动态生成和编译模块,这可能是一个问题。)



此外,还有一个小的开销在本地代码和仿真的BEAM代码之间跳转,所以您应该避免在速度重要的紧循环中使用这种模式切换。最好将所有紧密相关的模块编译为本机,如果可能的话也可以编写最重要的标准库模块。



最后,虽然本机编译器测试相当好, HiPE中的编译器错误比BEAM模拟器C代码中的错误高一点(尽管可能不高于GCC中的错误),所以您可能会冒更大的系统错误风险。这些天很少见。



总而言之,现在可能不推荐使用本地编译的主要地方是独立产品(如黑盒子您提供给客户的服务器),其中稳定性,远程可调试性和低内存使用率是您的主要关注点,而计算速度通常不是。


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?

解决方案

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.

这篇关于用“+本机”编译的约束/限制是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆