<p>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.</p>

<p>For example we have <a href="http://msdn.microsoft.com/en-us/library/k2wxda47.aspx" rel="noreferrer">DebuggableAttribute</a> which should be set to not debug and not disable optimization for optimal performance.</p>

<pre><code>[Debuggable(false, false)]
</code></pre>

<p>Are there any others I should know about?</p>

[{'answer_id': 70168, 'author': 'Lars Truijens', 'author_id': 1242, 'author_profile': 'https://Stackoverflow.com/users/1242', 'pm_score': 1, 'selected': False, 'text': '<p>I found another: <a href="http://msdn.microsoft.com/en-us/library/system.resources.neutralresourceslanguageattribute.aspx" rel="nofollow noreferrer">NeutralResourcesLanguageAttribute</a>. According to <a href="http://blogs.msdn.com/bclteam/archive/2005/10/11/479330.aspx" rel="nofollow noreferrer">this</a> blog post it helps the loader in finding the right satellite assemblies faster by specifying the culture if the current (neutral) assembly.</p>\n\n<pre><code>[NeutralResourcesLanguageAttribute("nl", UltimateResourceFallbackLocation.MainAssembly)]\n</code></pre>\n'}, {'answer_id': 74912, 'author': 'Lars Truijens', 'author_id': 1242, 'author_profile': 'https://Stackoverflow.com/users/1242', 'pm_score': 2, 'selected': False, 'text': '<p>And another: Literal strings (strings declared in source code) are by default <a href="http://msdn.microsoft.com/en-us/library/system.string.intern.aspx" rel="nofollow noreferrer">interned</a> into a pool to save memory. </p>\n\n<pre><code>string s1 = "MyTest"; \nstring s2 = new StringBuilder().Append("My").Append("Test").ToString(); \nstring s3 = String.Intern(s2); \nConsole.WriteLine((Object)s2==(Object)s1); // Different references.\nConsole.WriteLine((Object)s3==(Object)s1); // The same reference.\n</code></pre>\n\n<p>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.</p>\n\n<p>Using <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.compilationrelaxationsattribute.aspx" rel="nofollow noreferrer">CompilationRelaxationsAttribute</a> you can tell the JIT compiler that you really don\'t want it to intern all the literal strings.</p>\n\n<pre><code>[assembly: CompilationRelaxations(CompilationRelaxations.NoStringInterning)]\n</code></pre>\n'}, {'answer_id': 78260, 'author': 'Thomas Danecker', 'author_id': 9632, 'author_profile': 'https://Stackoverflow.com/users/9632', 'pm_score': 4, 'selected': True, 'text': '<p>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.</p>\n\n<p>Specifically CompilationRelaxations.RelaxedArrayExceptions and CompilationRelaxations.RelaxedNullReferenceException are mentioned there.</p>\n\n<p>It\'d be intersting what happens when you just try some integers in the CompilationRelaxationsAttribute\'s ctor ;)</p>\n'}]
['https://Stackoverflow.com/questions/70150', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1242/']