views:

747

answers:

4

What are the actual performance differences between Int64 and Int32 on 32 and 64 bit MS Windows?

It would also be great to see some actual timings of Int64 vs Int32 on each of the two operating system variants. XP or Vista would also be interesting.

  • See also this question about memcpy performance.
+4  A: 

As far as hardware, Int64 will be more efficient on an x64 and IA64 than x86 because the 64-Bit processors have 64-Bit registers to perform the operations on them.

Int32 will be equally as efficient on all x86, x64, and IA64.

On an x64 and on an IA64 both Int32 and Int64 are equally as efficient.

On an x86 Int32 will be more efficient than an Int64.

As far as the OS itself, I don't think you will see any extra performance issues than the performance results mentioned above.

Brian R. Bondy
Note that there is a very small advantage to 32-bit ints on all platforms since you only have to MV 4 bytes instead of 8. But this is really quite minor, and unlikely to give any discernible performance difference in most cases.
Zathrus
I don't think moving 8 bytes is slower than moving 4 bytes on an x64. Because it moves them all concurrently at the same time.
Brian R. Bondy
If you move 4 bytes on an 8 byte architechture, you need to zeroe out 4 bytes.
Burkhard
again you are writing all bytes concurrently at the hardware level so it doesn't matter.
Brian R. Bondy
Moving 32-bits on a 64-bit machine *may* sometimes actually be slower than moving 64-bits if a size override is required in the active segment.
Brian Knoblauch
I agree with that last point, but I would guess that most are equally as efficient.
Brian R. Bondy
A: 

From the hardware point of view, ie if the OS takes full advantage of the architechture, the Int64 will be more efficient on a 64 bit system.

Int32 may be slightly more efficient on a 32 bit system, since the 64 bit system may have to emulate the 32 bit operation.

Burkhard
+1  A: 

When in doubt, go with the int32. Not only is it faster on x86 architectures, and plenty of those are sitll around, but remember that your cache is finite, and you can fit twice as many int32 into your CPU cache as int64.

Enno
A: 

You may wish to follow SpankyJ's past entries on 64-bit development

http://blogs.msdn.com/joshwil/archive/2005/04/28/413320.aspx

icelava
Good link - many thanks :)
Thomas Bratt