Why do 64-bit applications work faster than 32-bit ones?

The difference in performance between 32-bit and 64-bit versions of applications depends greatly upon their types, and the data types they are processing. But in general you may expect a 2-20% performance gain from mere recompilation of a program - this is explained by architectural changes in 64-bit processors [1].

More general-purpose registers in such processors let you optimize work with local variables in functions which do not need to be saved into main memory anymore. Several function arguments are passed through registers and it also reduces the time to call them [2].

The extended address space eliminates the limitation concerning the maximum 4 Gbytes of main memory available on the 32-bit architecture. The possibility to store the whole necessary data set in the main memory allows avoidance of overly slow data swapping to the disk, and it lets some programs working with large data arrays get several times the performance gain.

However, the other side of the move to the 64-bit version is a two-time increase of the size of pointers and some other data types, which might result in an increased demand of the software to the system's physical memory. In some cases, it might slow down the speed of a 64-bit application in comparison to a 32-bit one. However, it occurs rarely and such cases are usually determined by an unsuccessful choice of the format in which data are stored in the program.

Note also that when you launch 32-bit versions of software on 64-bit systems of the Windows family, old 32-bit applications are executed a bit slower because of the WoW64 subsystem which emulates the 32-bit environment. An average performance loss because of this WoW64 layer is 2-3%, although in some special cases it might be much more.

References



Use PVS-Studio to search for bugs in C, C++ and C# code

We offer you to check your project code with PVS-Studio. Just one bug found in the project will show you the benefits of the static code analysis methodology better than a dozen of the articles.

goto PVS-Studio;



Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++ and C#

goto PVS-Studio;