October 7th, 2024

The costs of the i386 to x86-64 upgrade

The article examines the shift from 32-bit to 64-bit architecture, discussing its impact on code density, memory usage, performance, and the evolution of software demands and hardware capabilities.

Read original articleLink Icon
The costs of the i386 to x86-64 upgrade

The article discusses the transition from i386 (32-bit) to x86-64 (64-bit) architecture, focusing on the implications of this upgrade on code density, memory usage, and performance. It highlights the historical context of computing, where earlier 16-bit machines had significant limitations in memory and processing capabilities. The author explains the differences between Complex Instruction Set Computing (CISC) and Reduced Instruction Set Computing (RISC), emphasizing how code density affects the efficiency of programs. The transition to 32-bit architecture allowed for greater memory addressing capabilities, leading to the adoption of the ILP32 model, where integers, longs, and pointers were all 32 bits. However, as software demands grew, the shift to 64-bit architecture became necessary, introducing the LP64 model, which increased pointer sizes and allowed for larger memory addressing. While this transition enabled more sophisticated applications, it also raised concerns about code density and potential performance issues due to larger binary sizes and L1 cache thrashing. The author concludes by noting the unexpected size differences in installation images for FreeBSD, prompting further investigation into the implications of these architectural changes.

- The transition from 32-bit to 64-bit architecture has significant implications for code density and performance.

- CISC and RISC architectures present trade-offs in instruction complexity and memory usage.

- The ILP32 model was adopted for 32-bit systems, while LP64 became the standard for 64-bit systems.

- Larger binaries in 64-bit systems can lead to performance issues, particularly with L1 cache utilization.

- The article highlights the evolving demands of software and the need for corresponding hardware capabilities.

Link Icon 6 comments
By @fweimer - 6 months
Comparing PIE executables is a bit of an anachronism. They did not really exist when x86-64 was introduced. Position-dependent executables are more compact on i386 because its lack of PC-relative addressing (the %rip stuff on x86-64) does not matter.

That being said, the larger register set, the register-based calling convention, SSE2 for floating point math, PC-relative addressing (important for shared objects) together usually compensate the cost of wider pointers. Unless your workload happens to be pointer-heavy and fit into slightly less than 4 GiB of address space.

By @docfort - 6 months
A nice complement to this post is Mike Culbert’s article about how Apple chose to use 32-bit ARM6 instead of a 16-bit processor for reasons entirely unrelated to maximum memory size. http://waltersmith.us/newton/COMPCON-HW.pdf
By @M95D - 6 months
> Sadly, and as far as I can tell, x32 is pretty much abandonware today. Gentoo claims to support it but there are no official builds of any distribution I can find that are built in x32 mode.

It is supported, but the list of broken packages is rather long... [1]

You don't need an official build, as Gentoo builds itself and also cross-builds itself for any target and any ABI. In this case, you don't even need a cross-build.

Just install Gentoo x86_64 multilib, enable x32 support in kernel, enable abi_x86_x32 USE flag for the packages you want to test and run emerge to build them. They won't even interfere with the rest of the running system. See [2].

[1] https://github.com/gentoo/gentoo/blob/master/profiles/arch/a...

[2] https://wiki.gentoo.org/wiki/Multilib/Concepts

By @jcelerier - 6 months
> We can’t run the resulting binary. x32 is an ABI that impacts the kernel interface too, so these binaries cannot be executed on a regular x86-64 kernel. Sadly, and as far as I can tell, x32 is pretty much abandonware today. Gentoo claims to support it but there are no official builds of any distribution I can find that are built in x32 mode.

Which distro is this ? In debian I'm pretty sure CONFIG_X86_X32 was enabled in the kernel not too long ago, enabling this to work without issues. When I benchmarked it was on average 20% faster than x86_64 and used quite less memory for GUI apps IIRC - I think that for most utilities like coreutils, image viewers, file explorers, media players, etc. they'd benefit from it ; >4GB is only really meaningful for web browsers, compilers & interpreters, games and creative apps such as anything doing 3D, audio or large data processing.

By @ksec - 6 months
And I assume most will default to X86S soon(ish)?
By @johnklos - 6 months
So is the only difference between "x32" (sic) and 32 bit x86 with PAE the fact that "x32" can use full 64 bit registers?