为什么与本地C/C ++相比,JIT版本的语言仍然更慢并且内存效率更低? [英] Why are JIT-ed languages still slower and less memory efficient than native C/C++?

查看:97
本文介绍了为什么与本地C/C ++相比,JIT版本的语言仍然更慢并且内存效率更低?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解释器需要做很多额外的工作,因此可以理解,翻译器的运行速度明显慢于本机代码.但是C#或Java之类的语言具有JIT编译器,据说可以编译为平台本机代码.

Interpreters do a lot of extra work, so it is understandable that they end up significantly slower than native machine code. But languages such as C# or Java have JIT compilers, which supposedly compile to platform native machine code.

但是,根据基准看起来足够合法,在大多数情况下,速度还是比C/C ++慢2-4倍?当然,与平均优化的C/C ++代码相比,我的意思是.我很清楚JIT编译的优化好处以及它们产生代码的能力,这些代码比未经过优化的C + C ++更快.

And yet, according to benchmarks that seem legit enough, in most of the cases are still 2-4x times slower than C/C++? Of course, I mean compared to equally optimized C/C++ code. I am well aware of the optimization benefits of JIT compilation and their ability to produce code that is faster than poorly optimized C+C++.

在谈到Java内存分配的良好程度之后,为什么要使用

And after all that noise about how good the Java memory allocation is, why such a horrendous memory usage? 2x to 50x, on average about 30x times more memory is being used across that particular benchmark suite, which is nothing to sneeze at...

请注意,我不想启动WAR,而是在询问定义这些性能和效率指标的技术细节.

NOTE that I don't want to start a WAR, I am asking about the technical details which define those performance and efficiency figures.

推荐答案

某些差异的原因;

  • JIT编译器大多数情况下都可以快速编译,而跳过一些需要较长时间才能找到的优化.

  • JIT compilers mostly compile quickly and skip some optimizations that take longer to find.

VM通常会强制执行安全措施,这会降低执行速度.例如.除非保证在正确的范围内,否则数组访问始终在.Net中进行边界检查

VM's often enforce safety and this slows execution. E.g. Array access is always bounds checked in .Net unless guaranteed within the correct range

在C ++中使用SSE(如果适用,可以提高性能)很容易,而在当前VM上很难使用

Using SSE (great for performance if applicable) is easy from C++ and hard from current VM's

与其他方面相比,C ++中的性能在其他方面具有更高的优先级

Performance gets more priority in C++ over other aspects when compared to VM's

VM经常会保留一段时间未使用的内存,然后再返回到似乎使用"更多内存的操作系统.

VM's often keep unused memory a while before returning to the OS seeming to 'use' more memory.

某些虚拟机使对象的值类型为int/ulong ..,这增加了对象内存开销

Some VM's make objects of value types like int/ulong.. adding object memory overhead

某些VM的自动对齐数据结构浪费大量内存(以提高性能)

Some VM's auto-Align data structures a lot wasting memory (for performance gains)

某些VM将布尔值实现为int(4个字节),几乎没有关注内存保存.

Some VM's implement a boolean as int (4 bytes), showing little focus on memoryconservation.

这篇关于为什么与本地C/C ++相比,JIT版本的语言仍然更慢并且内存效率更低?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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