Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance of a C# application built on AnyCPU vs x64 platform on a 64 bit machine

Tags:

c#

.net

clr

I have to deploy a C# application on a 64 bit machine though there is a slight probability that it could also be deployed on a 32 bit machine. Should I build two separate executables targeting x86 and x64 platform or should I go for a single executable built targeting 'AnyCPU' platform (specified in the project property's Build option'. Would there be any performace difference between a C# assembly built targeting 'AnyCPU' is deployed on a 64 bit machine vs the same assembly built targeting specifically 'x64' platform ?

like image 754
Saurabh R S Avatar asked Jun 16 '12 08:06

Saurabh R S


People also ask

What is the performance of AC?

A room air conditioner's efficiency is measured by the energy efficiency ratio (EER). The EER is the ratio of the cooling capacity (in British thermal units (Btu) per hour) to the power input (in watts). The higher the EER rating, the more efficient the air conditioner.

How AC performance is measured?

Energy Efficiency Ratio (EER) and Seasonal Energy Efficiency Ratio (SEER) The EER and SEER are used for air-conditioning equipment, and both represent a ratio of cooling output in BTU to heating input in watt-hours. The metrics can also be used for heat pumps capable of running in cooling mode.

What affects AC performance?

The amount of area your AC has to cool, the location of the unit, the heat produced inside, and other significant factors combine to make a cooling load for the unit. The higher the cooling load, the harder it is for your air conditioner to cool efficiently.


2 Answers

No, there is no difference in performance between AnyCPU application running on a 64-bit Windows and an x64 application running on it. The only thing that flag changes are some flags in the header of the compiled assembly and the CLR uses it only to decide whether to use x86 or x64, nothing else

If you were asking whether there is a difference between x86 application running on a 64-bit Windows and an x64 (or AnyCPU), then the answer would be yes. The differences between the two are:

  • 64-bit obviously uses references that are twice as big as 32-bit, which means larger memory consumption, but it also means you can use more memory
  • 64-bit can use more registers that are available only in the 64-bit mode of CPUs
  • 64-bit JIT is different from 32-bit JIT, it has different set of optimizations: for example 64-bit JIT sometimes uses the tail call optimization even if you don't specifically request it using the tail. instruction (which for example C# never does)
like image 112
svick Avatar answered Oct 10 '22 01:10

svick


As a side note to the above answer. There can be issues with using P/Invoke or DotNetInterop into x86 DLL's on an x64 OS using AnyCPU. In the case where no 64-bit version of the DLL is available, it may be necessary to compile x86 rather than AnyCPU as the OS will try to load the 64-bit version...and fail.

like image 25
Tephyrnex Avatar answered Oct 10 '22 02:10

Tephyrnex