简体   繁体   English

有没有真正的点将Windows应用程序编译为64位?

[英]Is there any real point compiling a Windows application as 64-bit?

I'd confidently say 99% of applications we write don't need to address more than 2Gb of memory. 我自信地说,我们编写的99%的应用程序不需要处理超过2Gb的内存。 Of course, there's a lot of obvious benefit to the OS running 64-bit to address more RAM, but is there any particular reason a typical application would be compiled 64bit? 当然,运行64位的操作系统可以获得很多明显的好处来解决更多的内存,但是有一个特殊的原因是典型的应用程序可以编译为64位吗?

There are performance improvements that might see with 64-bit. 使用64位可能会看到性能改进。 A good example is that some parameters in function calls are passed via registers (less things to push on the stack). 一个很好的例子是函数调用中的一些参数是通过寄存器传递的(在栈上推送的东西较少)。

Edit I looked up some of my old notes from when I was studying some of the differences of running our product with a 64-bit build versus a 32-bit build. 编辑我查看了一些旧的笔记,当时我正在研究使用64位构建和32位构建运行产品的一些差异。 I ran the tests on a quad core 64-bit machine. 我在四核64位机器上运行测试。 So there is the question of comparing apples to oranges since the 32-bit was running under the emulation mode obviously. 因此,存在将苹果与橙子进行比较的问题,因为32位显然在仿真模式下运行。 However, it seems that many things I read such as this, for example, consistently say that the speed hit for WOW64 is not significant. 但是,似乎我读过的很多东西,例如,一直都说WOW64的速度并不重要。 But even if that statement is not true, your application will almost certainly be run on a 64-bit OS. 但即使该声明不正确,您的应用程序几乎肯定会在64位操作系统上运行。 Thus a comparison of a 32-bit build versus 64-bit on a 64-bit machine has value. 因此,在64位计算机上比较32位版本与64位版本具有价值。

In the testing I performed (certainly not comprehensive), I did not find any cases where the 32-bit build was faster. 在我执行的测试中(当然不全面),我没有发现任何32位版本更快的情况。 However many of the SQL intensive operations I ran (high CPU and high I/O) were 20% to 50% faster when running with the 64-bit build. 但是,当运行64位版本时,我运行的许多SQL密集型操作(高CPU和高I / O)的速度提高了20%到50%。 These tests involved some fairly “ugly” SQL statements and also some TPCC tests with high concurrency. 这些测试涉及一些相当“丑陋”的SQL语句以及一些具有高并发性的TPCC测试。 Of course, a lot depends on compiler switches quite a bit, so you need to do your own testing. 当然,很大程度上取决于编译器开关,所以你需要做自己的测试。

现在将它们构建为64位,即使您从未发布构建,也可以帮助您查找和修复以后在您被迫构建和发布为64位时遇到的问题。

x64 has eight more general purpose registers that aren't available when running 32-bit code. x64有8个通用寄存器,在运行32位代码时不可用。 That's three times as many (twice as many if you count ESI, EDI, EBP and ESP as general purpose; I don't). 这是三倍的数量(如果将ESI,EDI,EBP和ESP视为通用目标,则为两倍);我不这样做。 That can save a lot of loads and stores in functions that use more than four variables. 这可以在使用四个以上变量的函数中节省大量的加载和存储。

Don't underestimate the marketing value of offering a native 64-bit version of your product. 不要低估提供本机64位版本产品的营销价值。

Also, you might be surprised just how many people work on apps that require as much memory as they can get. 此外,您可能会惊讶于有多少人处理需要尽可能多内存的应用程序。

I'd say only do it if you need more that 2GB. 我要说只有你需要2GB以上才能做到这一点。

One thing is 64-bit compilation means (obviously) 64-bit pointers. 一件事是64位编译意味着(显然)64位指针。 That means the code and data structures get a bit bigger, meaning that the app. 这意味着代码和数据结构变得更大,意味着应用程序。 will benefit a little less from cache and will hit the virtual memory a bit more often etc. 将从缓存中受益少一点,并会更频繁地击中虚拟内存等。

So, if you don't need it, the basic effect is to make your app a bit slower and more bloated for no reason. 所以,如果你不需要它,基本的效果就是让你的应用程序慢慢变得更加膨胀,无缘无故。

That said, as time goes on, you'll care more about 64 bit anyway just because that's what all the tools and libraries etc will be written for. 也就是说,随着时间的推移,无论如何你都会更关心64位,因为这就是为所有工具和库等编写的。 Even if your app can live quite happily in 64K, you're unlikely to use 16 bit code - the gains don't really matter (it's a small fast app anyway) and are certainly outweighed by the hassle involved. 即使你的应用程序可以在64K中幸福地生活,你也不太可能使用16位代码 - 这些增益并不重要(无论如何它都是一个小的快速应用程序)并且肯定被所涉及的麻烦所抵消。 In time, we'll see 32-bit much the same way. 到时候,我们会以同样的方式看到32位。

You could consider it as future-proofing. 你可以认为它是面向未来的。 It may be a long way away, but consider some years in to the future, where 64-bit OS and CPUs are ubiquitous (consider how 16-bit faded away when 32-bit took over). 它可能还有很长的路要走,但考虑到未来几年,64位操作系统和CPU无处不在(考虑当32位接管时16位消失)。 If your application is 32-bit and all your competitors have moved on to 64-bit by then, your application could be seen as (or accused by your competitors as) out of date, slower, or incapable of change. 如果您的应用程序是32位且当时所有竞争对手都已转移到64位,那么您的应用程序可能会被视为(或被竞争对手指责为)过时,较慢或无法更改。 Maybe even one day support for 32-bit applications will be dropped or incomplete (can Windows 7 run 16-bit apps properly?). 也许甚至有一天对32位应用程序的支持将被删除或不完整(Windows 7能否正确运行16位应用程序?)。 If you're already building a 64-bit version of your application today, you avoid these problems. 如果您现在已经构建了64位版本的应用程序,则可以避免这些问题。 If you put it off till later, you might write a lot more code between now and when you port, then your port will be even harder. 如果你把它推迟到以后,你可能会在现在和你移植之间编写更多的代码,那么你的端口会更难。

For a lot of applications there aren't many compelling technical reasons, but if it's easy, porting now might save you effort in future. 对于许多应用程序而言,没有太多令人信服的技术原因,但如果它很容易,现在移植可能会节省您将来的工作量。

If you don't need the extended address space, delivering in 64 bits mode offers nothing and has some disadvantage like increasing the memory consumption and the cache pressure. 如果您不需要扩展地址空间,则以64位模式提供任何功能都不会产生任何问题,例如增加内存消耗和缓存压力。

While we offer 64 bits builds, our customer who are at the limit are pushing us to reduce the memory consumption so that they get these advantages. 虽然我们提供64位版本,但我们的客户正在推动我们减少内存消耗,以便他们获得这些优势。

所有可能需要大量内存的应用程序:想要在内存中缓存大量数据的数据库服务器,处理大量数据的科学应用程序,......

I've recently read this article, Optimizing software in C++ . 我最近读过这篇文章, 用C ++优化软件 In chapter 2.3 Choice of operating system there is a comparison between advantadges and disavantages of 64 and 32 bits system, with some specific observations regarding Windows. 在第2.3 Choice of operating system2.3 Choice of operating system对64位和32位系统的优势和劣势进行了比较,并对Windows进行了一些具体的观察。

Mark Wilkins already noted in this thread about more registers for function calls. Mark Wilkins在这个帖子中已经注意到有关函数调用的更多寄存器。 Another interesting property of 64 bit system is this: 64位系统的另一个有趣特性是:

The SSE2 instruction set is supported on all 64-bit CPUs and operating systems.

SSE2 instructions can provide excellent optimizations and they are being increasingly used, so in my opinion this is a notable feature. SSE2指令可以提供出色的优化,并且它们正在被越来越多地使用,因此在我看来这是一个值得注意的特性。

通过将前四个参数保存在寄存器中, Fastcall可以更快地调用子程序。

When you say that 99% of apps won't benefit from 64-bit, that may well be true for you personally, but during the day I use Visual Studio and Xcode to compile C++ with a large codebase, search the multi-Gb repositories with Google Desktop and Spotlight. 如果你说99%的应用程序不会从64位中受益,那对你个人来说可能就是这样,但白天我使用Visual Studio和Xcode编译具有大代码库的C ++,搜索多Gb存储库使用Google桌面和Spotlight。 Then I come home to write music using a sequencer using several Gb of sound libraries, and do some photoshopping on my 20Gb of photos, and maybe do a bit of video editing with my holiday clips. 然后我回家用一个使用几个Gb声音库的音序器写音乐,并在我的20Gb照片上做一些photoshopping,也许用我的假日剪辑进行一些视频编辑。

So for me (and I dare say many other users), having 64-bit versions of many of these apps will be a great advantage. 所以对我来说(我敢说很多其他用户),拥有64位版本的许多这些应用程序将是一个很大的优势。 Word processor, web browser, email client: maybe not. 文字处理器,网络浏览器,电子邮件客户端:也许不是 But anything involved with large media will really benefit. 但任何与大媒体有关的事情都会受益。

每个时钟周期可以处理更多数据,这可以提高例如加密,视频编码等应用的性能

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

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