本机 Erlang 模块和字节码 Erlang 模块之间的性能差异是什么?
本机 Erlang 模块和字节码 Erlang 模块之间的性能差异是什么?
What is the performance difference between native and bytecode Erlang modules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
对于实际上执行大量工作的代码(而不是花费大部分时间等待消息或调用内置函数),典型的加速将在 8 到 20 倍之间。
这在很大程度上还取决于代码的具体功能:浮点运算循环或二进制/位串操作往往会获得最佳加速,而更正常的元组和列表操作代码可能不会超过 8-10 倍快点。
另外,请记住,如果循环体主要调用未编译为本机代码的其他模块,则编译为本机代码的循环不会更快。
(我已经有一段时间没有查看新的基准测试结果了,但我认为没有发生太大变化。)
For code that actually does a lot of work (as opposed to spending most of its time waiting for messages or calling built-in functions), typical speedups would be between 8 and 20 times.
This also depends a lot on exactly what the code does: loops over floating point operations or manipulation of binaries/bitstrings tend to get the best speedups, while more normal tuple-and-list-manipulating code might not get more than 8-10 times faster.
Also, keep in mind that a loop compiled to native code will not be much faster if the loop body is mainly calling other modules that are not compiled to native.
(It's been a while since I looked at fresh benchmark results, but I don't think a lot has changed.)
已经有一些正确的答案,但我认为您实际上需要测量特定功能的性能。如果关键区域比字节码版本相当快,则可能仍然需要清理模块以使其故障安全。
There are a few correct answers already, but I think you would actually need to measure the performance of your particular functionality. If the critical region is reasonably faster than the bytecode version, there is probably still work to clean up the module to make it fail-safe.
在性能方面,HiPE 在模块内进行优化,而不是模块间调用。这可以产生非常好的加速(x4..x10 似乎是普遍吹捧的数字),但是正如其他人回答的那样,如果您的代码花费大量时间等待外部事件,则加速将可以忽略不计。
需要注意的是,HiPE 显然不支持某些渐进式语言功能,例如参数化模块。这意味着一些最近的应用程序(例如 MochiWeb)将根本无法运行。考虑到这一点。
Performance-wise, HiPE optimizes within modules - not inter-module calls. This can yield very good speedups (x4..x10 appear to be commonly touted numbers), however as others have replied, if your code spends a lot of time waiting for external events the speedup will be negligible.
Something to watch out for is that HiPE apparently does NOT support some progressive language features, such as Parameterized Modules. This means that some recent applications (such as MochiWeb) will not be runnable at all. Take this into account.
在相关说明中,您可能会发现本文很有用:
user.it.uu .se/~kostis/Papers/erlang03.pdf
除了描述使用 HiPE 产生的限制之外,它还进行了一些(非常基本的)速度比较。
我发现最值得注意的两件事是:
On a related note, you might find this paper useful:
user.it.uu.se/~kostis/Papers/erlang03.pdf
Amongst describing the limitations that arise from using HiPE, it also has some (very basic) speed comparisations.
The two things I've found most notable:
原生应该更快。我认为速度有多快并没有一个恒定的因素;根据机器/架构等的不同,它肯定是不同的。
Native should be faster. I don't think theres a constant factor how much faster it is; It is surely different based on machine/architecture and so on.