<p>I know that <code>.NET</code> is <code>JIT</code> compiled to the architecture you are running on just before the app runs, but does the JIT compiler optimize for 64bit architecture at all?  </p>

<p>Is there anything that needs to be done or considered when programming an app that will run on a <code>64bit system</code>? (i.e. Will using Int64 improve performance and will the JIT compiler automatically make Int64 work on 32bit systems?)</p>

[{'answer_id': 14452, 'author': 'T Percival', 'author_id': 954, 'author_profile': 'https://Stackoverflow.com/users/954', 'pm_score': 0, 'selected': False, 'text': "<p>Performance bottlenecks will be the same regardless of whether the architecture is 32- or 64-bit. Performance problems tend to be the result of sub-optimal algorithms &mdash; the choice between 32- and 64-bit types won't significantly affect performance.</p>\n\n<p>Most importantly, don't try to improve the performance of something before you've measured it. In particular you should profile the code to determine where your performance bottlenecks are.</p>\n"}, {'answer_id': 14462, 'author': 'Wilka', 'author_id': 1367, 'author_profile': 'https://Stackoverflow.com/users/1367', 'pm_score': 5, 'selected': True, 'text': '<p>The <a href="http://blogs.msdn.com/davbr/pages/tail-call-jit-conditions.aspx" rel="nofollow noreferrer">64bit JIT is different</a> from the one for 32bit, so I would expect some differences in the output - but I wouldn\'t switch to 64bit just for that, and I wouldn\'t expect to gain much speed (if any) in CPU time by switching to 64bit. </p>\n\n<p>You will notice a big performance improvement if your app uses a lot of memory and the PC has enough RAM to keep up with it. I\'ve found that 32bit .NET apps tend to start throwing out of memory exceptions when you get to around 1.6gb in use, but they start to thrash the disk due to <a href="http://en.wikipedia.org/wiki/Paging" rel="nofollow noreferrer">paging</a> long before that - so you end being I/O bound.</p>\n\n<p>Basically, if you\'re bottleneck is CPU then 64bit is unlikely to help. If your bottleneck is is memory then you should see a big improvement. </p>\n\n<blockquote>\n  <p>Will using Int64 improve performance and will the JIT compiler automatically make Int64 work on 32bit systems</p>\n</blockquote>\n\n<p>Int64 already works on both 32bit and 64bit systems, but it\'ll be faster running on 64bit. So if you\'re mostly number crunching with Int64, running on a 64bit system should help. </p>\n\n<p>The most important thing is to <a href="http://channel9vip.orcsweb.com/shows/Behind+The+Code/Rico-Mariani-Writing-better-faster-code/?CommentID=290154" rel="nofollow noreferrer">measure</a> your performance.</p>\n'}, {'answer_id': 69270, 'author': 'Bill Wert - MSFT', 'author_id': 10882, 'author_profile': 'https://Stackoverflow.com/users/10882', 'pm_score': 3, 'selected': False, 'text': '<p><a href="http://blogs.msdn.com/joshwil/archive/2006/07/18/670090.aspx" rel="nofollow noreferrer">This</a> is a good article on the subject, by one of the people who worked on the 64 bit JIT. Basically, unless you absolutely need the address space that 64 bit can offer, or need to do 64 bit math, you will likely lose performance. As pointers are larger, cache is effectively halved, for example.</p>\n'}, {'answer_id': 425061, 'author': 'Oliver Hallam', 'author_id': 19995, 'author_profile': 'https://Stackoverflow.com/users/19995', 'pm_score': 3, 'selected': False, 'text': '<p>I have noticed 64-bit being a lot slower.</p>\n\n<p>As has been stated the 64-bit JIT compiler behaves differently to the x86 JIT compiler.  The x86 compiler will take advantage of some optimizations that the x64 one does not.</p>\n\n<p>For example in .NET 3.5 the 32-bit JIT will inline function calls with structs as arguments, but the 64-bit JIT does not.</p>\n\n<p>In production code I have seen x86 builds running as much as 20% faster than x64 builds (with no other changes)</p>\n'}, {'answer_id': 2267624, 'author': 'Theodore Zographos', 'author_id': 320229, 'author_profile': 'https://Stackoverflow.com/users/320229', 'pm_score': 2, 'selected': False, 'text': '<p>To sum up, use 64-bit only if </p>\n\n<ol>\n<li>You need the extra memory and there is no way around it.</li>\n<li>You program e.g. scientific apps and need the increased math precision</li>\n</ol>\n\n<p>On every other aspect, as of today, the 64-bit compiler in .NET is one step down.</p>\n\n<p>Performance optimizations done in the .NET compilers are a big issue.</p>\n'}]
['https://Stackoverflow.com/questions/14432', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/194/']