7

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.
Community
  • 1
  • 1
Thomas Bratt
  • 48,038
  • 36
  • 121
  • 139

4 Answers4

9

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
  • 339,232
  • 124
  • 596
  • 636
  • 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 Nov 11 '08 at 17:48
  • 4
    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 Nov 11 '08 at 17:53
  • If you move 4 bytes on an 8 byte architechture, you need to zeroe out 4 bytes. – Burkhard Nov 11 '08 at 17:56
  • again you are writing all bytes concurrently at the hardware level so it doesn't matter. – Brian R. Bondy Nov 11 '08 at 17:57
  • 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 Nov 11 '08 at 17:57
  • I agree with that last point, but I would guess that most are equally as efficient. – Brian R. Bondy Nov 11 '08 at 18:10
4

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
  • 1,736
  • 17
  • 32
-1

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
  • 14,596
  • 22
  • 87
  • 108
  • that all is just wrong. the OS is no interpreter of machine code. int64 is larger, less cache-able, slower in multiplication, but AND,OR,XOR,COMP,NOT etc are equally fast, and relative memory-addressing on a 64bit memory model is done via 8bit and 64bit registers - not 32bit registers. amd64 is backwards compatible to x86 – no emulation. – comonad Mar 28 '11 at 20:50
-1

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
  • 9,787
  • 7
  • 52
  • 74