简体   繁体   中英

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 long s to int s, but still same result.

Please advise.

Peter

Edit:

  • About memory, both 32 and 64 versions use similar memory, about 1.5 ~ 2.5 GB, and my machine has 9GB physical memory;
  • I profiled using OProfile, and for most of the functions, the 64bit version collects more profiling samples than the 32bit version;
  • I cannot think of any other bottlenecks, please advise.
  • My app is a server, and the loading test was done under a 100 client connections. The server does a lot of computation processing the audio data from the clients.

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

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM