Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

64bit .NET Performance tuning

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

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

like image 681
Adam Haile Avatar asked Aug 18 '08 10:08

Adam Haile


People also ask

Why 64-bit is faster than 32?

Computer Performance Using 64 bit operating system with 64 bit processer, the system can perform an increased number of calculations per second. As a result, it increases the processing power and makes a computer run faster. This is limited in case of 32 bit operating system.

Does 64-bit software run faster?

Simply put, a 64-bit processor is more capable than a 32-bit processor because it can handle more data at once. A 64-bit processor can store more computational values, including memory addresses, which means it can access over 4 billion times the physical memory of a 32-bit processor. That's just as big as it sounds.

Does a 32 bit apps run faster on 64-bit os?

Short answer, yes. In general any 32 bit program runs slightly faster than a 64 bit program on a 64 bit platform, given the same CPU.

Is 64-bit slower?

The difference in performance between 32-bit and 64-bit versions of applications depends greatly upon their types, and the data types they are processing. But in general you may expect a 2-20% performance gain from mere recompilation of a program - this is explained by architectural changes in 64-bit processors [1].


2 Answers

The 64bit JIT is different 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.

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 paging long before that - so you end being I/O bound.

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.

Will using Int64 improve performance and will the JIT compiler automatically make Int64 work on 32bit systems

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.

The most important thing is to measure your performance.

like image 145
Wilka Avatar answered Oct 28 '22 03:10

Wilka


This 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.

like image 39
Bill Wert - MSFT Avatar answered Oct 28 '22 03:10

Bill Wert - MSFT