哪些属性有助于运行时 .Net 性能?
我正在寻找可用于通过向加载器、JIT 编译器或 ngen 提供提示来确保 .Net 应用程序获得最佳运行时性能的属性。
例如,我们有 DebuggableAttribute ,应将其设置为不调试且不禁用优化以获得最佳性能。
[Debuggable(false, false)]
还有其他我应该了解的吗?
I am looking for attributes I can use to ensure the best runtime performance for my .Net application by giving hints to the loader, JIT compiler or ngen.
For example we have DebuggableAttribute which should be set to not debug and not disable optimization for optimal performance.
[Debuggable(false, false)]
Are there any others I should know about?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我找到了另一个:NeutralResourcesLanguageAttribute。 根据 这篇 博客文章,它可以帮助加载程序通过指定当前(中性)程序集的区域性,可以更快地找到正确的附属程序集。
I found another: NeutralResourcesLanguageAttribute. According to this blog post it helps the loader in finding the right satellite assemblies faster by specifying the culture if the current (neutral) assembly.
另一个:文字字符串(在源代码中声明的字符串)默认为 驻留到池中以节省内存。
虽然多次使用同一个文字字符串时可以节省内存,但维护池会花费一些 cpu,并且一旦将字符串放入池中,它就会一直保留在那里,直到进程停止。
使用 CompilationRelaxationsAttribute 你可以告诉 JIT 编译器你真的不希望它保留所有的文字字符串。
And another: Literal strings (strings declared in source code) are by default interned into a pool to save memory.
Although it saves memory when the same literal string is used multiple times, it costs some cpu to maintaining the pool and once a string is put into the pool it stays there until the process is stopped.
Using CompilationRelaxationsAttribute you can tell the JIT compiler that you really don't want it to intern all the literal strings.
Ecma-335 在附件 F“不精确的错误”中指定了更多用于宽松异常处理(所谓的 e-relaxed 调用)的 CompilationRelaxations,但 Microsoft 尚未公开它们。
具体来说,那里提到了 CompilationRelaxations.RelaxedArrayExceptions 和 CompilationRelaxations.RelaxedNullReferenceException 。
当您在 CompilationRelaxationsAttribute 的构造函数中尝试一些整数时,会发生什么,这会很有趣;)
Ecma-335 specifies some more CompilationRelaxations for relaxed exception handling (so-called e-relaxed calls) in Annex F "Imprecise faults", but they have not been exposed by Microsoft.
Specifically CompilationRelaxations.RelaxedArrayExceptions and CompilationRelaxations.RelaxedNullReferenceException are mentioned there.
It'd be intersting what happens when you just try some integers in the CompilationRelaxationsAttribute's ctor ;)