I use C#, .NET, VS.NET 2008.
我使用C#,.NET,VS.NET 2008。
Besides being able to address more memory, what are the advantages to compiling my application to 64-bit?
除了能够处理更多内存外,将我的应用程序编译为64位有什么好处?
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)?
它是否使它与x64系统更兼容(与32位应用程序相比)?
5 个解决方案
#1
16
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.
对于本机应用程序,您可以获得诸如增加地址空间等诸多好处。但是,.NET应用程序在CLR上运行,它抽象出任何底层架构差异。
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.
假设您只是处理托管代码,那么定位特定平台没有任何好处;你最好只使用“anycpu”标志集进行编译(默认情况下是打开的)。这将生成平台无关的程序集,这些程序集将在运行CLR的任何体系结构上运行良好。
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.
专门针对(比方说)x64不会给你带来任何性能提升,并且会阻止你的程序集在32位平台上运行。
This article has a bit more information on the subject.
本文提供了有关该主题的更多信息。
Update: Scott Hanselman just posted a good overview of this topic as well.
更新:Scott Hanselman刚刚也对这个主题做了很好的概述。
#2
4
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.
从理论上讲,为x64编译的程序运行速度比为x86编译的程序运行得快。这是因为x64架构中有更多通用寄存器。 32位x86只有4个通用寄存器。 AMD在其x64扩展中增加了8个通用寄存器。这允许更少的内存负载和(略微)更快的性能。
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.
二进制文件的大小和内存占用量将比使用64位指令略有增加,但由于x64仍然是CISC架构,因此二进制大小不会像RISC架构那样加倍。大多数指令的长度仍然短于64位。
#3
3
AS the matter of fact, 64Bit applications that do not require large memory space tend to work slower. One of the reasons behind it is that you have to move move data around. If you can not utilize >2GB memory space (for caching for example), I wouldn't recommend it.
事实上,不需要大内存空间的64位应用程序往往工作得更慢。其背后的原因之一是您必须移动移动数据。如果你不能利用> 2GB的内存空间(例如用于缓存),我不推荐它。
Here's an interesting link I just found http://www.osnews.com/story/5768 with a lot of info.
这是一个有趣的链接,我刚刚找到http://www.osnews.com/story/5768,有很多信息。
#4
2
I doubt it (given the C#/.NET platform), unless you are using Native Code. Remember, .NET managed code is compiled to IL, and the platform switch defaults to anycpu, so you should get better performance on 64-bit OS with your existing binary:
我怀疑它(给定C#/。NET平台),除非你使用的是Native Code。请记住,.NET托管代码编译为IL,平台交换机默认为anycpu,因此您应该使用现有二进制文件在64位操作系统上获得更好的性能:
http://blogs.msdn.com/gauravseth/archive/2006/03/07/545104.aspx
This article has a ton of useful information including regarding the CorFlags tool which will let you inspect a PE header.
本文提供了大量有用的信息,包括CorFlags工具,它可以让您检查PE头。
In general, for native code binaries, yes.
通常,对于本机代码二进制文件,是的。
#5
0
I'm really not an expert at CPU architectures, so take my comments lightly. Wikipedia has a an article describing the x86-64 architecture (link text).
我真的不是CPU架构方面的专家,所以请轻轻一点。*有一篇描述x86-64架构(链接文本)的文章。
The x86-64 has more registers, this alone should help to make a program faster. Also this new architecture offers new instruction sets which could improve speed if the compiler takes advantage of it.
x86-64有更多的寄存器,仅这一点就可以帮助提高程序的速度。此外,这种新架构还提供了新的指令集,如果编译器利用它,可以提高速度。
Another factor to take into account is the number of instruction sets available. When a program is compiled to x86 usually it's target is to to run into all existing 32-bit CPUS (Pentium 1, 2, 3, 4, core* etc). Each new CPU generation adds new instructions sets, this instructions can't be used by a program that wants to be fully portable in binary format among all x86 CPUS. As x86-64 bit is a new architecture, recompiling a program for this machine gives the compiler a wider set of instructions to use without worrying too much about binary compatibility among diff 64-bit CPUS.
另一个需要考虑的因素是可用的指令集数量。当程序编译为x86时,它的目标是运行所有现有的32位CPUS(Pentium 1,2,3,4,core *等)。每个新的CPU生成都添加了新的指令集,这个指令不能被希望在所有x86 CPUS中以二进制格式完全移植的程序使用。由于x86-64位是一种新架构,因此重新编译该机器的程序可为编译器提供更广泛的指令集,而无需过多担心diff 64位CPUS之间的二进制兼容性。
#1
16
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.
对于本机应用程序,您可以获得诸如增加地址空间等诸多好处。但是,.NET应用程序在CLR上运行,它抽象出任何底层架构差异。
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.
假设您只是处理托管代码,那么定位特定平台没有任何好处;你最好只使用“anycpu”标志集进行编译(默认情况下是打开的)。这将生成平台无关的程序集,这些程序集将在运行CLR的任何体系结构上运行良好。
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.
专门针对(比方说)x64不会给你带来任何性能提升,并且会阻止你的程序集在32位平台上运行。
This article has a bit more information on the subject.
本文提供了有关该主题的更多信息。
Update: Scott Hanselman just posted a good overview of this topic as well.
更新:Scott Hanselman刚刚也对这个主题做了很好的概述。
#2
4
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.
从理论上讲,为x64编译的程序运行速度比为x86编译的程序运行得快。这是因为x64架构中有更多通用寄存器。 32位x86只有4个通用寄存器。 AMD在其x64扩展中增加了8个通用寄存器。这允许更少的内存负载和(略微)更快的性能。
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.
二进制文件的大小和内存占用量将比使用64位指令略有增加,但由于x64仍然是CISC架构,因此二进制大小不会像RISC架构那样加倍。大多数指令的长度仍然短于64位。
#3
3
AS the matter of fact, 64Bit applications that do not require large memory space tend to work slower. One of the reasons behind it is that you have to move move data around. If you can not utilize >2GB memory space (for caching for example), I wouldn't recommend it.
事实上,不需要大内存空间的64位应用程序往往工作得更慢。其背后的原因之一是您必须移动移动数据。如果你不能利用> 2GB的内存空间(例如用于缓存),我不推荐它。
Here's an interesting link I just found http://www.osnews.com/story/5768 with a lot of info.
这是一个有趣的链接,我刚刚找到http://www.osnews.com/story/5768,有很多信息。
#4
2
I doubt it (given the C#/.NET platform), unless you are using Native Code. Remember, .NET managed code is compiled to IL, and the platform switch defaults to anycpu, so you should get better performance on 64-bit OS with your existing binary:
我怀疑它(给定C#/。NET平台),除非你使用的是Native Code。请记住,.NET托管代码编译为IL,平台交换机默认为anycpu,因此您应该使用现有二进制文件在64位操作系统上获得更好的性能:
http://blogs.msdn.com/gauravseth/archive/2006/03/07/545104.aspx
This article has a ton of useful information including regarding the CorFlags tool which will let you inspect a PE header.
本文提供了大量有用的信息,包括CorFlags工具,它可以让您检查PE头。
In general, for native code binaries, yes.
通常,对于本机代码二进制文件,是的。
#5
0
I'm really not an expert at CPU architectures, so take my comments lightly. Wikipedia has a an article describing the x86-64 architecture (link text).
我真的不是CPU架构方面的专家,所以请轻轻一点。*有一篇描述x86-64架构(链接文本)的文章。
The x86-64 has more registers, this alone should help to make a program faster. Also this new architecture offers new instruction sets which could improve speed if the compiler takes advantage of it.
x86-64有更多的寄存器,仅这一点就可以帮助提高程序的速度。此外,这种新架构还提供了新的指令集,如果编译器利用它,可以提高速度。
Another factor to take into account is the number of instruction sets available. When a program is compiled to x86 usually it's target is to to run into all existing 32-bit CPUS (Pentium 1, 2, 3, 4, core* etc). Each new CPU generation adds new instructions sets, this instructions can't be used by a program that wants to be fully portable in binary format among all x86 CPUS. As x86-64 bit is a new architecture, recompiling a program for this machine gives the compiler a wider set of instructions to use without worrying too much about binary compatibility among diff 64-bit CPUS.
另一个需要考虑的因素是可用的指令集数量。当程序编译为x86时,它的目标是运行所有现有的32位CPUS(Pentium 1,2,3,4,core *等)。每个新的CPU生成都添加了新的指令集,这个指令不能被希望在所有x86 CPUS中以二进制格式完全移植的程序使用。由于x86-64位是一种新架构,因此重新编译该机器的程序可为编译器提供更广泛的指令集,而无需过多担心diff 64位CPUS之间的二进制兼容性。