.NET 运行时与 Java Hotspot:.NET 落后一代了吗?

发布于 2024-09-12 16:34:51 字数 571 浏览 8 评论 0原文

根据我在.NET和Java执行环境上收集到的信息,目前的情况如下:

抛开基准测试不谈,并且无意升级圣战,这是否意味着 Java Hotspot VM 领先 .Net 一代。 Java VM 中使用的这些技术最终会进入 .NET 运行时吗?

According to the information I could gather on .NET and Java execution environment, the current state of affairs is follows:

Benchmarks aside and with no intention to escalate holy wars, does this mean that Java Hotspot VM is one generation ahead of .Net. Will these technologies employed at Java VM eventually find its way into .NET runtime?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

∞梦里开花 2024-09-19 16:34:51

他们遵循两种不同的策略。我不认为其中一个比另一个更好。

  • .NET 不解释字节码,因此它必须在执行时对所有内容进行 JIT,因此由于时间限制而无法进行大量优化。如果您需要对代码的某些部分进行大量优化,您始终可以手动 NGEN,或者执行快速但 不安全实现。此外,调用本机代码很容易这里的方法似乎是让运行时足够好并手动优化瓶颈

  • 现代 JVM 通常会解释大部分代码,然后对瓶颈进行优化编译。这通常比直接 JIT 获得更好的结果,但如果您需要更多,Java 中没有 unsafe,并且 调用本机代码不太好所以这里的方法是尽可能多地进行自动优化,因为其他选项都不太好

实际上,与 .NET 相比,Java 应用程序在时间上的性能往往稍好,但在空间上的性能较差。

They follow two different strategies. I do not think one is better than the other.

  • .NET does not interpret bytecode, so it has to JIT everything as is gets executed and therefore cannot optimise heavily due to time constraints. If you need heavy optimizations in some part of the code, you can always NGEN it manually, or do a fast but unsafe implementation. Furthermore, calling native code is easy. The approach here seems to be getting the runtime good enough and manually optimise bottlenecks.

  • Modern JVMs will usually interpret most of the code, and then do an optimized compilation of the bottlenecks. This usually gets better results than straight JIT'ing, but if you need more, you don't have unsafe in Java, and calling native code is not nice. So the approach here is to do as much automatic optimising as possible, because the other options are not that good.

In reality Java applications tend to perform slightly better in time and worse in space when compared to .NET.

诠释孤独 2024-09-19 16:34:51

我从来没有对两者进行过基准测试来进行比较,而且我更熟悉Sun JVM,我只能笼统地谈论JIT。

优化总是需要权衡,并且并非所有优化始终有效。然而,这里有一些现代 JIT 技术。我认为,如果我们坚持技术性的内容,这可能是一次良好对话的开始:

还有一些有用的功能VM 的良好实现:

  • 能够在 GC
  • 实现之间进行选择 每个 GC
  • 堆分配参数的自定义(例如增长)
  • 页面锁定

基于这些功能以及更多功能,我们可以比较 VM,而不仅仅是“Java”与“. NET”,但是,比如说,Sun 的 JVM 与 IBM 的 JVM 对比 .NET 与 Mono。

例如,Sun 的 JVM 不执行尾部调用优化 IIRC,但 IBM 的 JVM 执行尾部调用优化。

I've never benchmarked the two to compare, and I'm more familiar with the Sun JVM, I can only speak in general terms about JITs.

There are always tradeoffs with optimizations, and not all optimizations work all the time. However, here are some modern JIT techniques. I think this can be the beginning of a good conversation if we stick to the technical stuff:

There's also features that are helpful as far as good implementations of a VM go:

  • being able to pick between GC
  • implementations customization of each GC
  • heap allocation parameters (such as growth)
  • page locking

Based on these features and many more, we can compare VMs, and not just "Java" versus ".NET" but, say, Sun's JVM versus IBM's JVM versus .NET versus Mono.

For example, Sun's JVM doesn't do tail-call optimization, IIRC, but IBM's does.

就是爱搞怪 2024-09-19 16:34:51

显然有人正在为 转子。我无法访问 IEEE,因此无法阅读摘要。

.NET JIT 编译器的动态重新编译和配置文件引导优化

引自摘要。 ..

使用以下方法对框架进行评估
一组测试程序表明
性能可以提高最大
42.3%,平均下降 9%。 我们的
结果还表明,管理费用
收集准确的个人资料
通过仪器仪表获取信息
在一定程度上超过了所带来的好处
我们的配置文件引导优化
实施
,表明需要
用于实现可以
减少此类开销。

Apparently someone was working on something similar for Rotor. I don't have access to IEEE so I can't read the abstract.

Dynamic recompilation and profile-guided optimisations for a .NET JIT compiler

Quote from Summary...

An evaluation of the framework using a
set of test programs shows that
performance can improve by a maximum
of 42.3% and by 9% on average. Our
results also show that the overheads
of collecting accurate profile
information through instrumentation to
an extent outweigh the benefits of
profile-guided optimisations in our
implementation
, suggesting the need
for implementing techniques that can
reduce such overheads.

旧情别恋 2024-09-19 16:34:51

您可能对 SPUR 感兴趣,是一个跟踪 JIT 编译器。重点是 javascript,但它在 CIL 上运行,而不是语言本身。这是一个基于 Bartok 的研究项目,而不是标准的 .NET VM。该论文有一些性能基准测试,显示“它始终比标准 3.5 CLR 的 SPUR-CLR 执行得更快”。然而,还没有任何关于与当前虚拟机相关的未来的公告。跟踪可以跨越方法边界,这不是 HotSpot 所做的事情 AFAIK,提到了 JVM 跟踪 JIT 这里

我不太愿意说 .NET VM 落后了一代,尤其是在考虑所有子系统(特别是泛型)时。 GCDLR 与 invokedynamic 比较 我不确定,但有很多有关它们的详细信息,请访问 channel9 等位置。

You may be interested in SPUR which is a Tracing JIT compiler. The focus is on javascript but it operates on CIL not the language itself. It is a research project based on Bartok not the standard .NET VM. The paper has some performance benchmarks showing 'it consistently performs faster than SPUR-CLR' which is the standard 3.5 CLR. There haven't been any announcements about it's future relating to the current VM however. Traces can cross method boundaries which is not something HotSpot does AFAIK, JVM tracing JITs are mentioned here.

I'd be hesitant to say the .NET VM is a generation behind especially when considering all the sub-systems, in particular generics. How the GC and DLR vs invokedynamic compare I'm unsure but there are lots of details about them at places like channel9.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文