提供 64 位特定版本的软件 [英] Supplying 64 bit specific versions of your software

查看:13
本文介绍了提供 64 位特定版本的软件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过将本机 C++ 客户端和服务器构建为 64 位代码,我是否希望看到任何性能提升?

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

什么样的应用程序可以从 64 位特定版本中受益?

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

我想任何广泛使用 long 的东西都会受益,或者任何需要大量内存(即超过 2Gb)的应用程序,但我不确定还有什么.

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.

推荐答案

Intel x64 与 x86 的架构优势

  • 更大的地址空间
  • 更丰富的寄存器组
  • 可以链接外部库或加载 64 位插件

x64 模式的架构缺点

  • 所有指针(因此也有很多指令)占用了 2 倍的内存,在最坏的情况下将有效的处理器缓存大小减少了一半
  • 无法链接外部库或加载 32 位插件

在我编写的应用程序中,当切换到 64 位时,我有时会看到大幅加速 (30%),有时会看到大幅减速 (> 2x).在我注册绑定的数字处理/视频处理应用程序中发生了巨大的加速.

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.

在转换为 64 位时,我在自己的代码中看到的唯一一个大的减速是来自一个巨大的指针追踪应用程序,其中一个编译器做了一些非常糟糕的优化".另一个编译器生成的代码性能差异可以忽略不计.

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.

现在移植的好处

编写 64 位兼容代码在 99% 的情况下都不是那么难,只要您知道要注意什么.大多数情况下,它归结为在引用内存地址时使用 size_t 和 ptrdiff_t 而不是 int (我在这里假设 C/C++ 代码).将大量未编写为 64 位感知的代码转换可能会很痛苦.

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.

即使为您的应用程序进行 64 位构建没有意义(可能没有),也值得花时间了解构建构建所需的内容,以便至少所有新代码并且未来的重构将兼容 64 位.

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.

这篇关于提供 64 位特定版本的软件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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