Peter Lee
Peter Lee

Reputation: 13839

Why 64Bit version app is much slower than 32Bit version

In order to solve the 3G (Ubuntu) memory issue (sometimes we do need more memory than 3G), I compiled my app under a 64bit environment to use more memory.

But, my 64bit app is much slower than the 32bit version.

32Bit version is built on a 32 bit machine; 64Bit version is build on a 64 bit machine; both 32Bit and 64Bit versions run on the 64Bit machine in our loading test.

I googled, and some folks said, the unnecessary long type can make the 64bit slower than 32bit, because:

man g++:

   -m64
       Generate code for a 32-bit or 64-bit environment.  The 32-bit environment
       sets int, long and pointer to 32 bits and generates code that runs on any
       i386 system. The 64-bit environment sets int to 32 bits and long and
       pointer to 64 bits and generates code for AMD's x86-64 architecture. For
       darwin only the -m64 option turns off the -fno-pic and -mdynamic-no-pic
       options.

So I changed all my longs to ints, but still same result.

Please advise.

Peter

Edit:

Upvotes: 2

Views: 2009

Answers (2)

phuclv
phuclv

Reputation: 41962

  1. For the question "why", no one will know the reason without details. You must analyze the profiled result and if there are any problem with the result, post it as a question here.

  2. If your app does not need more than 4GB of RAM (1.5~2.5GB in your case), you should try x32. It's a new ABI that allows for 32-bit pointers in 64-bit environment.

Upvotes: 2

Kylotan
Kylotan

Reputation: 18449

Profile your app. That will tell you where the slow code is.

Upvotes: 4

Related Questions