在.NET中调试和诊断锁运送问题 [英] Debugging and diagnosing lock convoying problems in .NET

查看:60
本文介绍了在.NET中调试和诊断锁运送问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究大型C#/.NET 3.5系统的性能问题,随着提出请求的用户数量每秒扩展到40-50个不同的用户请求,该系统的性能会下降.

I am looking into performance issues of a large C#/.NET 3.5 system that exhibits performance degradation as the number of users making requests scales up to 40-50 distinct user requests per second.

请求持续时间显着增加,而CPU和I/O负载似乎保持不变.这使我相信我们可能对系统中使用c#lock() {...}语句保护的共享对象可能会影响并发访问性能存在疑问.具体来说,我怀疑在受关键节保护的频繁使用的共享数据上会发生某种程度的锁定(因为它是读/写的).

The request durations increase significantly, while CPU and I/O loads appear to stay about the same. This leads me to believe we may have problem with how shared objects in our system, which are protected using c# lock() {...} statements may be affecting concurrent access performance. Specifically, I suspect that some degree of lock convoying is occurring on frequently used shared data that is protected by critical sections (because it it read/write).

是否有人对如何实际诊断是否存在锁队问题提出建议,或者是否存在任何类型的锁争用导致请求时间长的建议?

推荐答案

锁定车队通常很难调试.您的代码路径是直接在分支中还是在分支中具有顺序锁语句?

Lock convoys are hard to debug in general. Does your code path have sequential lock statements either directly or in branches?

争用总数#a 性能计数器给出了基本估算值在应用程序中的争用.

The Total # of Contentions performance counter gives a base estimate of contention in the app.

也请打开分析器并查看.您还可以编写一些性能计数器来跟踪代码路径的慢速部分.另外,请确保仅在绝对必要的时间内保留锁.

Also break open a profiler and look. You can also write some perf counters to track down the slow parts of a code path. Also make sure that locks are only being held for as long as absolutely necessary.

也请查看 Windows性能工具.我发现这些功能非常有用,因为您可以跟踪许多底层问题,例如异常数量的上下文切换.

Also check out the Windows Performance Tools. I have found these to be extremely useful as you can track down lots of low level problems like abnormal amounts of context switching.

这篇关于在.NET中调试和诊断锁运送问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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