.Net 4.0 应用程序在 64 位上比 32 位慢(分析和可能的解决方案)(应用程序使用 NetAdvantage) [英] .Net 4.0 app slower on 64 bit than 32 bit (Profiling and possible solutions) (app is using NetAdvantage)

查看:14
本文介绍了.Net 4.0 应用程序在 64 位上比 32 位慢(分析和可能的解决方案)(应用程序使用 NetAdvantage)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有用 VB .NET 4.0/VS2010 编写的 .NET 应用程序,编译时将所有项目都设置为 AnyCPU 设置以进行调试和发布配置.我们注意到,当这个应用程序在 64 位环境中运行(在 Windows Server 2003 R2 和 2008 R2 上测试)时,该应用程序需要至少两倍的时间(绝对值大约 25 秒),而不是大约 6-12在 32 位环境(Win XP 和 7)上启动需要几秒钟.

We have got .NET app written in VB .NET 4.0 / VS2010, compiled with all projects set to the AnyCPU setting for both Debug and Release configuration. We have noticed that when this app is run on a 64 bit environment (tested on Windows Server 2003 R2 and 2008 R2) that the app then takes at least double as long (in absolute terms about 25 secs) as opposed to around 6-12 seconds on a 32 bit environment (Win XP and 7) to start up.

我应该补充一点,64 位系统是强大的服务器,绝对比其他经过测试的 32 位系统更强大.所有其他应用程序在 64 位上都更快,但不是我们糟糕的应用程序;)(我们确实在不同时间、不同负载下测试了应用程序,结果总是几乎相同.)

I should add that the 64 bit systems are powerful servers, definitely more powerful than the other tested 32 bit systems. All other apps were faster on 64 bit, but not our poor app ;) (And we did test the apps at different times, under different load, and the results are always pretty much the same.)

如上所述,该应用程序是使用 AnyCPU 构建的,它确实在 64 位操作系统下作为 64 位程序集运行(通过 TaskManager 检查).该应用程序本身是一个 WinForms 应用程序,使用 NetAdvantage Forms v10.3,并定期查询和写入 MS SQL Server 2008.

As said above, the app is built using AnyCPU and it does run as 64 bit assembly under 64 bit OS (checked via TaskManager). The app itself is a WinForms app, making use of NetAdvantage Forms v10.3 and is regularly querying and writing to MS SQL Server 2008.

不同的目标机器都在同一个网络上,所以数据库的路径(性能测试使用的是同一个数据库)是一样的,我认为问题不在数据库或网络上本身.

The different target machines are all on the same network, so the path to the database (same database was used for the performance tests) for example is the same, I don't think the problem is around the database or the network itself.

我注意到的一件事对我来说似乎很奇怪,当我在 MainForm 启动期间使用秒表构建不同的分析步骤"时,InitializeComponent 方法在 64 位上花费了两倍的时间,大约 4 秒与 32 位的 1.5 相对.

One thing I did notice, which seemed odd to me, was that when I built in different "profiling steps" using a stopwatch during the startup of our MainForm that the InitializeComponent method took twice as long on 64 bit, around 4 seconds opposed to 1.5 on 32 bit.

这是我们在两个系统上部署的完全相同的应用程序,没有不同的配置.

It's the very same app we deploy on both systems, no different config.

所以我有两个问题:

知道这可能是什么原因吗?

Any idea what the cause of this could be?

以及:确定违规"代码段的最佳方法是什么?目前我使用秒表并尝试缩小范围.但在我看来,就我们的应用而言,在 64 位机器上一切都变慢了,所以我不太确定是否可以将其分解为特定的语句.

And: What's the best way of determining the "offending" pieces of code? Currently I use stopwatches and try to narrow it down. But it looks to me like everything is slower on the 64 bit machines as far as our app is concerned, so I am not too sure I can break it down to specific statements.

感谢大家的帮助,非常感谢...

Thanks all for your help, very much appreciated...

推荐答案

事实证明,一旦我们从编译从 AnyCPU 切换到专门的 x86,即也在 x64 位平台上以 x86 运行,我们又回到了我们的好速度".

It turned out, that as soon as we switched from compiling from AnyCPU to specifically x86, i.e. also run as x86 on a x64 bit platform, we were back to our "good speed".

这篇关于.Net 4.0 应用程序在 64 位上比 32 位慢(分析和可能的解决方案)(应用程序使用 NetAdvantage)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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