在64位操作系統中運行32位.NET應用程序,真的很糟糕嗎?

[英]Running 32bit .NET application in 64bit OS, is it really bad?


I understand that we can compile a .NET Application by targeting AnyCPU which will cause to run 32bit in a 32bit OS and 64bit in a 64bit OS.

我知道我們可以通過定位AnyCPU來編譯.NET應用程序,這將導致在32位操作系統中運行32位,在64位操作系統中運行64位。

However there was a reported bug* on a 64bit OS that my app was giving an error and the solutions for that, I need to target x86.

然而,在64位操作系統上有一個報告錯誤*,我的應用程序出錯並為此解決方案,我需要針對x86。

Now my question: Is it really bad to target x86 even though when your code is going to run in x64? What sort of performance we are talking about? (my application is quite CPU intensive but it's really hard to come up with )

現在我的問題是:即使你的代碼要在x64中運行,定位x86真的很糟糕嗎?我們在談論什么樣的表現? (我的應用程序非常占用CPU,但很難想出來)

After all .NET Framework will run in 32bit which sounds bad to me instead of taking the full addressing power of x64 CPU**.

畢竟.NET Framework將在32位運行,這對我來說聽起來不好,而不是取得x64 CPU **的完全尋址能力。

*I can't remember the bug but the solution was targeting x86 specifically, and solved the problem.

*我不記得該錯誤,但解決方案專門針對x86,並解決了問題。

** I'm not sure if it's any important but my application doesn't use any Int64 variables.

**我不確定它是否有任何重要但我的應用程序不使用任何Int64變量。

9 个解决方案

#1


No, it's not bad; In fact, for an application I'm working on, I have to target x86 (as it brings in COM objects, for which the vendor doesn't support x64)

不,這不錯;事實上,對於我正在處理的應用程序,我必須針對x86(因為它帶來了COM對象,供應商不支持x64)

#2


I have had a number crunching application that used CPU a lot (brute forcing some solution). Running it on 64 bit .NET Framework (8 seconds) was about 4 times faster than 32 bit (30 seconds). That's just a single case though.

我有一個使用CPU的數字運算應用程序(暴力強制解決方案)。在64位.NET Framework上運行它(8秒)比32位(30秒)快大約4倍。這只是一個案例。

#3


No, it's not that bad to need to target x86 on x64 systems. You will miss out on the extra x64 benefits and end up running in the 32bit emulation layer. But that's better than being completely broken, and most apps out there are still 32bit.

不,需要在x64系統上定位x86並不是那么糟糕。您將錯過額外的x64優勢,並最終在32位仿真層中運行。但這比完全破壞要好,而且大多數應用仍然是32位。

With .Net, the normal reason to need to do this is a dependency on a native 32-bit only dll. If you leave your .Net targeted from any cpu it will try to load your 32-bit dll in 64-bit mode, resulting in a crash. Ultimately, you do want to move away from that dependency so you can use 64-bit mode. But for one release it won't kill you.

對於.Net,需要這樣做的正常原因是依賴於原生的32位dll。如果從任何cpu中保留.Net目標,它將嘗試以64位模式加載32位dll,從而導致崩潰。最終,您確實希望擺脫該依賴關系,以便您可以使用64位模式。但是對於一個版本它不會殺了你。

#4


The answer is "it depends." It depends on what your application does, whether it accesses memory a lot or not. Kevin is right: the processor does have to do address translation a lot, but this probably won't hurt the performance of your application too much. The underlying hardware instructions are mostly the same between x86 and amd64 and there is not too much inefficiency there assuming the CLR authors knew what they were doing (and I'm sure they did). You might see a big performance difference if you're doing graphics manipulation, but since this is just a .NET app, I don't think you are. For some number crunching tasks you might notice a difference as Mehrdad mentioned, though I'd be surprised if you did.

答案是“這取決於”。這取決於你的應用程序做什么,它是否訪問內存很多。凱文是對的:處理器確實需要進行大量的地址轉換,但這可能不會對應用程序的性能造成太大影響。假設CLR作者知道他們在做什么(並且我確信他們確實這樣做了),那么底層硬件指令在x86和amd64之間基本相同,並且沒有太多低效率。如果你正在進行圖形處理,你可能會看到很大的性能差異,但由於這只是一個.NET應用程序,我認為你不是。對於一些數字運算任務,你可能會注意到Mehrdad提到的不同,盡管如果你這樣做我會感到驚訝。

All-in-all, I would say not to worry about the performance issues unless you have a performance-sensitive application. Then only worry about performance issues once you understand the nature of your application.

總而言之,我要說的是不要擔心性能問題,除非你有一個對性能敏感的應用程序。一旦您了解了應用程序的性質,那么只需擔心性能問題。

#5


If you use structures allot, and have lot's of 64 bit computations (double, long) then you'll see a performance decrease due to the 32bit Jit engine being less advanced compared to the 64bit one.

如果您使用結構分配,並且有大量的64位計算(雙倍,長),那么由於32位Jit引擎與64位引擎相比不太先進,您將看到性能下降。

Otherwise the 32bit and 64 bit version of .Net are somewhat similar performance wise.

否則32位和64位版本的.Net在性能方面有些相似。

And also if you don't need to exceed 2GB limit for your process you do not need 64 bit for addressing capabilities, the OS takes care of that for you using a special CPU mode called Long Mode - Compatibility SubMode. (The CPU is actually running in 64 bit mode, but using 32bit for addressing, for compatibility)

此外,如果您的過程不需要超過2GB的限制,您不需要64位的尋址功能,操作系統會為您使用稱為長模式 - 兼容性子模式的特殊CPU模式。 (CPU實際上是以64位模式運行,但使用32位進行尋址,以實現兼容性)

#6


What you have to remember is that to get a 32-bit process to run in a 64-bit environment the system has to do a memory address translation for everything it does. Is it bad? It depends on the scenario. It definately isn't as efficient as it could be. Running a 32 bit verion of IIS on an x-64 server is painfully slow compared to what it could be. It all depends on what your needs of the application are.

您必須記住的是,要使32位進程在64位環境中運行,系統必須對其執行的所有操作進行內存地址轉換。這不好嗎?這取決於場景。它絕對不是那么有效。在x-64服務器上運行32位版本的IIS與可能的情況相比非常緩慢。這完全取決於您對應用程序的需求。

#7


No. It will run without issues. In fact, we've often found our 32 bit apps run on 64bit Vista better than on 32 bit Vista, due to the newer OS memory manager. Targetting x86 directly should work fine. However, being able to run natively on 64bit will have other advantages, like the ability to access more memory, more registers for CPU, etc., so is worth putting the effort into getting up and running if possible.

不會。它會毫無問題地運行。事實上,由於較新的操作系統內存管理器,我們經常發現我們的32位應用程序在64位Vista上運行比在32位Vista上更好。直接針對x86應該可以正常工作。但是,能夠在64位本地運行將具有其他優勢,例如訪問更多內存的能力,更多用於CPU的寄存器等,因此值得盡可能地投入運行。

#8


I was going to say best way to tell for sure if to measure, but obviously if it won't run properly then it's kinda hard to measure.

我打算說出最好的方法來確定是否要測量,但顯然如果它不能正常運行那么它很難衡量。

First of all see if there's a performance problem. If it seems like it is a problem then see if you can pinpoint what it is exactly in the app that isn't x64 compliant. Most .NET code should be platform independent, so the most likely culprit is any native inter-op or 3rd party libraries.

首先看看是否存在性能問題。如果它看起來像是一個問題,那么看看你是否可以確定它在不符合x64的應用程序中的確切含義。大多數.NET代碼應該是獨立於平台的,因此最可能的罪魁禍首是任何本地的inter-op或第三方庫。

#9


Has your "bug" been that your .NET code uses a 32-bit COM object?

您的“錯誤”是否是您的.NET代碼使用32位COM對象?

This case might indeed be a problem when running a .NET process on a 64-bit architecture which has been compiled with the AnyCPU setting.

在使用AnyCPU設置編譯的64位體系結構上運行.NET進程時,這種情況可能確實存在問題。

The reason is that the process will be executed as a 64-bit process and any COM componetne which gets executed in process also must be a 64-bit version. If this is not the case your process will quit.

原因是該進程將作為64位進程執行,並且在進程中執行的任何COM組件也必須是64位版本。如果不是這種情況,您的流程將退出。

A possible solution is to set your target platform to x86.

可能的解決方案是將目標平台設置為x86。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/04/06/7210d9689d3b0940efc4430eca0b157.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com