简体   繁体   English

为什么64位版本的应用程序比32位版本慢得多

[英]Why 64Bit version app is much slower than 32Bit version

In order to solve the 3G (Ubuntu) memory issue (sometimes we do need more memory than 3G), I compiled my app under a 64bit environment to use more memory. 为了解决3G(Ubuntu)内存问题(有时我们确实需要比3G更多的内存),我在64位环境下编译了我的应用程序以使用更多的内存。

But, my 64bit app is much slower than the 32bit version. 但是,我的64位应用程序比32位版本慢得多。

32Bit version is built on a 32 bit machine; 32位版本建立在32位计算机上; 64Bit version is build on a 64 bit machine; 64位版本建立在64位计算机上; both 32Bit and 64Bit versions run on the 64Bit machine in our loading test. 在我们的负载测试中,32位和64位版本均在64位计算机上运行。

I googled, and some folks said, the unnecessary long type can make the 64bit slower than 32bit, because: 我用谷歌搜索,有些人说,不必要的long类型会使64位比32位慢,因为:

man g++:

   -m64
       Generate code for a 32-bit or 64-bit environment.  The 32-bit environment
       sets int, long and pointer to 32 bits and generates code that runs on any
       i386 system. The 64-bit environment sets int to 32 bits and long and
       pointer to 64 bits and generates code for AMD's x86-64 architecture. For
       darwin only the -m64 option turns off the -fno-pic and -mdynamic-no-pic
       options.

So I changed all my long s to int s, but still same result. 因此,我将所有long s都更改为int ,但结果仍然相同。

Please advise. 请指教。

Peter 彼得

Edit: 编辑:

  • About memory, both 32 and 64 versions use similar memory, about 1.5 ~ 2.5 GB, and my machine has 9GB physical memory; 关于内存,32和64版本都使用相似的内存,大约1.5〜2.5 GB,并且我的机器具有9GB的物理内存。
  • I profiled using OProfile, and for most of the functions, the 64bit version collects more profiling samples than the 32bit version; 我使用OProfile进行了分析,对于大多数功能,64位版本比32位版本收集更多的分析样本。
  • I cannot think of any other bottlenecks, please advise. 我认为没有其他瓶颈,请告知。
  • My app is a server, and the loading test was done under a 100 client connections. 我的应用是一台服务器,负载测试是在100个客户端连接下完成的。 The server does a lot of computation processing the audio data from the clients. 服务器进行了大量计算处理来自客户端的音频数据。

Profile your app. 设定您的应用程式。 That will tell you where the slow code is. 这将告诉您慢速代码在哪里。

  1. For the question "why", no one will know the reason without details. 对于“为什么”的问题,没有细节,没人会知道原因。 You must analyze the profiled result and if there are any problem with the result, post it as a question here. 您必须分析概要分析的结果,如果结果有任何问题,请在此处将其发布为问题。

  2. If your app does not need more than 4GB of RAM (1.5~2.5GB in your case), you should try x32 . 如果您的应用程序不需要超过4GB的RAM(在您的情况下为1.5〜2.5GB),则应尝试x32 It's a new ABI that allows for 32-bit pointers in 64-bit environment. 这是一个新的ABI ,允许在64位环境中使用32位指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM