TargetedPatchingOptOut:"性能的关键跨越NGEN图像边界内联"? [英] TargetedPatchingOptOut: "Performance critical to inline across NGen image boundaries"?

查看:518
本文介绍了TargetedPatchingOptOut:"性能的关键跨越NGEN图像边界内联"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经经历了一些框架类使用反射镜,发现了一些方法和属性有下列属性

Been going through some framework classes using reflector and noticed a number of the methods and properties have the following attribute

[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]

我是pretty的肯定,我也看到了上述评论别的地方,从来也没有遵循它。

I'm pretty sure I have also seen the above comment somewhere else and never followed it up.

可能有人请告诉我这是什么意思在C#和其他方面?

Could someone please tell me what this means in the C# and any other context?

推荐答案

它告诉NGEN,这是OK内联它的应用方法,即使在不同的装配。

It tells NGen that it is OK to inline the method it's applied to even in a different assembly.

例如:

  • String.Equals [TargetedPatchingOptOut]
  • 您编写一个程序,调用 String.Equals
  • 您对这个项目的最高性能运行 NGEN
  • NGEN将内联 String.Equals 通话,与实际code的方法替换方法调用指令。
    方法调用(略)贵,所以这是一个性能提升对于经常调用的方法。
  • String.Equals has [TargetedPatchingOptOut]
  • You write a program that calls String.Equals
  • You run NGen on this program for maximum performance
  • NGen will inline the String.Equals call, replacing the method call instruction with the actual code in the method.
    Method calls are (slightly) expensive, so this is a performance boost for frequently-called methods.

不过,如果微软发现在 String.Equals 安全漏洞,他们不能只更新 mscorlib.dll中,因为这会不会影响你刚才NGen'd大会。 (因为它有没有引用原机code String.Equals )。
我认为,如果这是实际发生的,此安全更新将清零NGEN店。

However, if Microsoft finds a security hole in String.Equals, they cannot just update mscorlib.dll, because that won't affect the assembly that you just NGen'd. (Since it has raw machine code without referencing String.Equals).
I assume that if that were to actually happen, the security update would clear the NGen store.

请注意,此属性仅在.NET框架组件是有用的。你不需要在你自己的。你可以找到这里的更多信息: http://stackoverflow.com/a/14982340/631802

Note that this attribute is only useful in the .NET Framework assemblies. You don't need it in your own. You can find more information about that here: http://stackoverflow.com/a/14982340/631802

这篇关于TargetedPatchingOptOut:"性能的关键跨越NGEN图像边界内联"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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