有没有什么办法来改变.NET JIT编译器有利于在编译时性能? [英] Is there any way to change the .NET JIT compiler to favor performance over compile time?

查看:251
本文介绍了有没有什么办法来改变.NET JIT编译器有利于在编译时性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何方法来改变.NET JIT编译器的行为,通过指定preference进行更深入的优化。如果做不到这一点,那将是很好,如果它可以做某种档案导引优化,如果没有了。

I was wondering if there's any way to change the behavior of the .NET JIT compiler, by specifying a preference for more in-depth optimizations. Failing that, it would be nice if it could do some kind of profile-guided optimization, if it doesn't already.

推荐答案

这是当你编译程序集设置。有两种类型的优化:

This is set when you compile your assembly. There are two types of optimizations:

  • IL优化
  • 在JIT本土code质量。

默认设置是这样的

 /optimize- /debug-

这意味着未优化的IL,优化本地code。

This means unoptimized IL, and optimized native code.

 /optimize /debug(+/full/pdbonly)

这意味着未优化的IL,并没有优化本地code(最佳调试设置)。

This means unoptimized IL, and unoptimized native code (best debug settings).

最后,为了获得最快的性能:

Finally, to get the fastest performance:

/optimize+ /debug(-/+/full/pdbonly)

这会产生IL优化,优化本地code。

This produces optimized IL and optimized native code.

在生产未优化的IL,编译器会插入所有在code NOP指令。这使得code更容易调试允许断点要在控制流指令,如用于设置,同时,如果,否则,尝试,抓等。

When producing unoptimized IL, the compiler will insert NOP instructions all over the code. This makes code easier to debug by allowing breakpoints to be set on control flow instructions such as for, while,if,else, try, catch etc.

在CLR做优化code不管是一个非常好的工作。一旦一个方法JIT'ed,通话或callvirt指令指针直接指向本地code。

The CLR does a remarkably good job of optimizing code regardless. Once a method is JIT'ed, the pointer on a call or a callvirt instruction is pointed directly to the native code.

此外,在CLR JIT'ing您code时,会采取任何可用的架构招数优势。这意味着一个组件通过JIT跑将运行速度比汇编pre-编译使用NGEN(尽管有一个稍微慢的启动时间),因为NGEN将编译适用于所有平台,并没有采取任何技巧优势

Additionally, the CLR will take advantage of any architecture tricks available when JIT'ing your code. This means that an assembly ran through the JIT will run faster than an assembly pre-compiled by using Ngen (albeit with a slightly slower start up time), as NGen will compile for all platforms, and not take advantage of any tricks.

这篇关于有没有什么办法来改变.NET JIT编译器有利于在编译时性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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