Windows 7 上的 LINQ 性能缓慢

发布于 2024-12-05 09:52:30 字数 642 浏览 1 评论 0原文

我有一个 .net 3.5 应用程序在 Windows XP x86 双核上运行。 我现在已经在带有超线程的四核 Windows 7 x64 上安装了该应用程序。 该应用程序是一个 GUI,它通过 WCF 与 Windows 服务进行通信,而 Windows 服务则通过 Linq2Sql 与 SQLExpress 2008 R2 进行通信。 我们还使用 Windsor Castle 进行依赖注入/IoC

XP 环境中的某个 Linq2Sql 语句大约需要 1.5-2 秒。在 Windows 7 中,此语句大约需要 5-7 秒。我已经运行了 sql profiler 和资源监视器,应用程序似乎等待了大约 5 秒,然后触发了实际的 sql 查询。因此延迟似乎发生在我的 Datacontext 下方和数据库之前

我尝试了以下操作:

  • 将连接字符串更改为 sql 身份验证
  • 拔掉网络电缆
  • 卸载防病毒程序
  • 禁用 LLMNR
  • 删除网卡上的 IPv6
  • 添加 transactionscope 并在代码中读取未提交的内容
  • 尝试添加锁(多线程环境)
  • 尝试将应用程序固定到一个
  • 以管理员身份运行的

CPU我的理论是有些东西超时了,但是什么?!?

I have a .net 3.5 application running in production on Windows XP x86 dualcore.
I have now installed the application on windows 7 x64, quadcore with hyperthreading.
The application is a gui which communicates through WCF with a windows service that communicates with SQLExpress 2008 R2 through Linq2Sql.
We also use Windsor Castle for Dependency Injection/IoC

A certain Linq2Sql statement in the XP-environment takes about 1,5-2 seconds. In windows 7 this statment takes about 5-7 seconds. I have run sql profiler and resource monitor and it seems that the application waits for about 5 seconds and then fires the actual sql-query. so the delay seems to occur below my Datacontext and before the database

I have tried the following:

  • changed the connection string to sql authentication
  • unplugged the network cable
  • uninstalled the antivirus program
  • disabled LLMNR
  • Removed IPv6 on the network cards
  • added transactionscopes with read uncommitted in the code
  • tried to add locks (multithreaded environment)
  • tried to pin the application to one cpu
  • run as admin

My theory is that something is timing out, but what?!?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山有枢 2024-12-12 09:52:30

我认为你必须慢慢添加代码才能找到问题 - 分而治之。

如果是对数据库的实际请求花费了时间,那么这实际上与 Win 7 和 Win XP 上的应用程序无关。直接向数据库发起查询时,该查询的速度有多快?如果速度很快,则向上移动调用堆栈...

Windows 服务有多快?你能向它发出一个请求,看看它有多快吗?

WCF 层有多快?直接打它能看到慢吗?那么你就找到了罪魁祸首。

接下来,看看您的 UI - 如果您制作一个小测试应用程序来测试应用程序的底部,它会很慢吗?如果没有,请继续向上。

最后,通过从上到下添加日志语句可以轻松完成其中一些操作,这样您就可以隔离问题,就像 @Jan 所建议的那样

I think you are going to have to slowly add in your code to find the issue - divide and conquer.

If it is the actual request to the database that is taking the time, then this isn't actually related to your application on Win 7 vs Win XP. How fast does this query take when firing it against the database directly? If this is fast, move up the call stack...

How fast is the Windows Service? Can you make a request to it, and see how fast that is?

How fast is the WCF layer? Can you hit it directly and see it is slow? Then you have found your culprit.

Next, on to your UI - is it slow if you make a little test app that exercises the bottom of the application? If not, keep moving up.

In the end, some of this can easily be accomplished by adding logging statements from the top to the bottom, so you can isolate the issue, just like suggested by @Jan

尾戒 2024-12-12 09:52:30

当将目标平台设置为 x86 而不是 AnyCPU 时,程序将按预期运行。所以问题似乎是 Linq2Sql 和 x64 并没有真正一起发挥作用。我不知道我们是否可以将其视为错误,但无论如何它的行为都很糟糕。

When setting the target platform to x86 instead of AnyCPU the program behaves as expected. So the problem seems to be that Linq2Sql and x64 doesn't really play together. I don't know if we can get it as a bug but it behaves bad any way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文