Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supplying 64 bit specific versions of your software

Would I expect to see any performance gain by building my native C++ Client and Server into 64 bit code?

What sort of applications benefit from having a 64 bit specific build?

I'd imagine anything that makes extensive use of long would benefit, or any application that needs a huge amount of memory (i.e. more than 2Gb), but I'm not sure what else.

like image 448
John Sibly Avatar asked Nov 27 '08 15:11

John Sibly


1 Answers

Architectural benefits of Intel x64 vs. x86

  • larger address space
  • a richer register set
  • can link against external libraries or load plugins that are 64-bit

Architectural downside of x64 mode

  • all pointers (and thus many instructions too) take up 2x the memory, cutting the effective processor cache size in half in the worst case
  • cannot link against external libraries or load plugins that are 32-bit

In applications I've written, I've sometimes seen big speedups (30%) and sometimes seen big slowdowns (> 2x) when switching to 64-bit. The big speedups have happened in number crunching / video processing applications where I was register-bound.

The only big slowdown I've seen in my own code when converting to 64-bit is from a massive pointer-chasing application where one compiler made some really bad "optimizations". Another compiler generated code where the performance difference was negligible.

Benefit of porting now

Writing 64-bit-compatible code isn't that hard 99% of the time, once you know what to watch out for. Mostly, it boils down to using size_t and ptrdiff_t instead of int when referring to memory addresses (I'm assuming C/C++ code here). It can be a pain to convert a lot of code that wasn't written to be 64-bit-aware.

Even if it doesn't make sense to make a 64-bit build for your application (it probably doesn't), it's worth the time to learn what it would take to make the build so that at least all new code and future refactorings will be 64-bit-compatible.

like image 133
Mr Fooz Avatar answered Oct 23 '22 09:10

Mr Fooz