Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can compiling my application for 64-bit make it faster or better?

Tags:

c#

.net

64-bit

I use C#, .NET, VS.NET 2008.

Besides being able to address more memory, what are the advantages to compiling my application to 64-bit?

Is it going to be faster or smaller? Why?

Does it make it more compatible with a x64 system (when compared to a 32-bit application)?

like image 268
Jason Avatar asked Jan 31 '09 05:01

Jason


People also ask

In what ways can 64-bit computing improve performance?

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.

Why are 64bit programs faster?

With 64 bit memory addresses the application can access more memory than its 32 bit equivalent. In addition 64 bit programs will work "better" than 32 bit ones as they are using the native system architecture. Operations such as memory reads are performed natively etc.

Will upgrading to 64-bit improve performance?

Benefits of 64-Bits: The main perks gained from installing a 64-bit version of Windows are the ability to access RAM above the 4-GB range and the advanced security features. The access to more memory allows for more efficiency when administering processes and consequently improves performance of the OS.

Do 64-bit programs run faster than 32-bit?

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


2 Answers

For native applications, you get benefits like increased address space and whatnot. However, .NET applications run on the CLR which abstracts away any underlying architecture differences.

Assuming you're just dealing with managed code, there isn't any benefit to targeting a specific platform; you're better off just compiling with the "anycpu" flag set (which is on by default). This will generate platform agnostic assemblies that will run equally well on any of the architectures the CLR runs on.

Specifically targeting (say) x64 isn't going to give you any performance boost, and will prevent your assemblies from working on a 32-bit platform.

This article has a bit more information on the subject.

Update: Scott Hanselman just posted a good overview of this topic as well.

like image 120
AwesomeTown Avatar answered Sep 22 '22 08:09

AwesomeTown


In theory, a program compiled for x64 will run faster than a program compiled for x86. The reason for this is because there are more general purpose registers in the x64 architecture. 32-bit x86 has only 4 general purpose registers. AMD added an additional 8 general purpose registers in their x64 extensions. This allows for fewer memory loads and (slightly) faster performance.

In reality, this doesn't make a huge difference in performance, but it should make a slight one.

The size of the binary and the memory footprint will increase somewhat from using 64-bit instructions but because x64 is still a CISC archictecture, the binary size does not double as it would in a RISC architecture. Most instructions are still shorter than 64 bits in length.

like image 36
Steve Rowe Avatar answered Sep 19 '22 08:09

Steve Rowe