且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

TargetedPatchingOptOut:"性能的关键跨越NGEN图像边界内联"?

更新时间:2022-05-17 10:22:50

它告诉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://***.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://***.com/a/14982340/631802