64 位程序是否比 32 位版本更大更快? [英] Are 64 bit programs bigger and faster than 32 bit versions?

查看:28
本文介绍了64 位程序是否比 32 位版本更大更快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我专注于 x86,但我通常对从 32 位迁移到 64 位感兴趣.

I suppose I am focussing on x86, but I am generally interested in the move from 32 to 64 bit.

从逻辑上讲,我可以看到常量和指针在某些情况下会更大,因此程序可能会更大.并且希望在字边界上分配内存以提高效率意味着分配之间有更多的空白.

Logically, I can see that constants and pointers, in some cases, will be larger so programs are likely to be larger. And the desire to allocate memory on word boundaries for efficiency would mean more white-space between allocations.

我还听说 x86 上的 32 位模式在上下文切换时必须刷新其缓存,因为可能存在重叠的 4G 地址空间.

I have also heard that 32 bit mode on the x86 has to flush its cache when context switching due to possible overlapping 4G address spaces.

那么,64 位的真正好处是什么?

So, what are the real benefits of 64 bit?

作为补充问题,128位会更好吗?

And as a supplementary question, would 128 bit be even better?

我刚刚编写了我的第一个 32/64 位程序.它生成 16 字节(32b 版本)或 32 字节(64b 版本)对象的链表/树,并大量打印到 stderr - 不是一个真正有用的程序,也不是典型的程序,但它是我的第一个.

I have just written my first 32/64 bit program. It makes linked lists/trees of 16 byte (32b version) or 32 byte (64b version) objects and does a lot of printing to stderr - not a really useful program, and not something typical, but it is my first.

尺寸:81128(32b) v 83672(64b) - 所以差别不大

Size: 81128(32b) v 83672(64b) - so not much difference

速度:17s(32b) v 24s(64b) - 在 32 位操作系统 (OS-X 10.5.8) 上运行

Speed: 17s(32b) v 24s(64b) - running on 32 bit OS (OS-X 10.5.8)

更新:

我注意到正在开发一种新的混合 x32 ABI(应用程序二进制接口),它是 64b 但使用 32b 指针.对于某些测试,它会生成比 32b 或 64b 更小的代码和更快的执行速度.

I note that a new hybrid x32 ABI (Application Binary Interface) is being developed that is 64b but uses 32b pointers. For some tests it results in smaller code and faster execution than either 32b or 64b.

https://sites.google.com/site/x32abi/

推荐答案

除非您需要访问 32b 寻址允许的更多内存,否则好处很小.

Unless you need to access more memory that 32b addressing will allow you, the benefits will be small, if any.

在 64b CPU 上运行时,无论您运行 32b 还是 64b 代码(您使用相同的缓存和相同的 BUS),您都会获得相同的内存接口.

When running on 64b CPU, you get the same memory interface no matter if you are running 32b or 64b code (you are using the same cache and same BUS).

虽然 x64 架构有更多的寄存器,可以更轻松地进行优化,但这通常会被指针现在更大的事实抵消,并且使用任何带有指针的结构都会导致更高的内存流量.我估计 64b 应用程序的总体内存使用量与 32b 应用程序相比增加了大约 15-30%.

While x64 architecture has a few more registers which allows easier optimizations, this is often counteracted by the fact pointers are now larger and using any structures with pointers results in a higher memory traffic. I would estimate the increase in the overall memory usage for a 64b application compared to a 32b one to be around 15-30 %.

这篇关于64 位程序是否比 32 位版本更大更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆