有没有什么办法来改变.NET JIT编译器有利于在编译时性能?编译器、有没有什么、性能、办法

由网友(◇◆狂傲的资本シ)分享简介:我想知道是否有任何方法来改变.NET JIT编译器的行为,通过指定preference进行更深入的优化。如果做不到这一点,那将是很好,如果它可以做某种档案导引优化,如果没有了。I was wondering if there's any way to change the behavior of the .NET J...

我想知道是否有任何方法来改变.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.

阅读全文

相关推荐

最新文章