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

后端 未结 2 1899
无人共我
无人共我 2020-12-29 02:46

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 ex

2条回答
  •  囚心锁ツ
    2020-12-29 03:09

    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)

提交回复
热议问题