如何衡量锁争用?

发布于 2024-08-15 20:02:35 字数 1003 浏览 3 评论 0原文

我正在阅读 http://lse.sourceforge.net/locking/dcache/dcache_lock.html ,其中测量每个函数的自旋锁时间:

SPINLOCKS         HOLD            WAIT
  UTIL  CON    MEAN(  MAX )   MEAN(  MAX )(% CPU)     TOTAL NOWAIT SPIN RJECT  NAME
  5.3% 16.5%  0.6us(2787us)  5.0us(3094us)(0.89%)  15069563 83.5% 16.5%    0%  dcache_lock
 0.01% 10.9%  0.2us( 7.5us)  5.3us( 116us)(0.00%)    119448 89.1% 10.9%    0%    d_alloc+0x128
 0.04% 14.2%  0.3us(  42us)  6.3us( 925us)(0.02%)    233290 85.8% 14.2%    0%    d_delete+0x10
 0.00%  3.5%  0.2us( 3.1us)  5.6us(  41us)(0.00%)      5050 96.5%  3.5%    0%    d_delete+0x94

我想知道这些统计数据来自哪里。我尝试了oprofile,但oprofile似乎无法测量特定锁的锁持有和等待时间。而且 valgrind 的 drd 会使应用程序速度减慢太多,这会使结果不太准确,并且也会消耗太多时间。 mutrace 看起来不错,但正如名字所示,我'恐怕它只能跟踪互斥锁排除。

那么有没有其他工具,或者如何使用我上面提到的工具来获取锁争用统计信息?

感谢您的回复。

I'm reading http://lse.sourceforge.net/locking/dcache/dcache_lock.html, in which spinlock time for each functions is measured:

SPINLOCKS         HOLD            WAIT
  UTIL  CON    MEAN(  MAX )   MEAN(  MAX )(% CPU)     TOTAL NOWAIT SPIN RJECT  NAME
  5.3% 16.5%  0.6us(2787us)  5.0us(3094us)(0.89%)  15069563 83.5% 16.5%    0%  dcache_lock
 0.01% 10.9%  0.2us( 7.5us)  5.3us( 116us)(0.00%)    119448 89.1% 10.9%    0%    d_alloc+0x128
 0.04% 14.2%  0.3us(  42us)  6.3us( 925us)(0.02%)    233290 85.8% 14.2%    0%    d_delete+0x10
 0.00%  3.5%  0.2us( 3.1us)  5.6us(  41us)(0.00%)      5050 96.5%  3.5%    0%    d_delete+0x94

I'd like to know where these statistics are from. I tried oprofile, but it seems oprofile cannot measure lock holding and waiting time for a specific lock. And valgrind's drd slows down applications too much, which will make the result less accurate and also consume too much time. mutrace seems good, but as the name points out, I'm afraid it can only trace mutex exclusions.

So is there any other tool, or how to use the tools I mentioned above, to get lock contention statistics?

Thanks for your reply.

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

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

发布评论

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

评论(2

单挑你×的.吻 2024-08-22 20:02:35

最后找到了文中使用的性能测量工具,需要对内核进行补丁。

介绍页面可以在http://oss.sgi.com/projects/lockmeter/,最新内核补丁对应内核版本2.6.16,可以下载这里

Finally I find the performance measuring tool used in the article, which needs to patch kernel .

The introduction page can be found at http://oss.sgi.com/projects/lockmeter/, and the latest kernel patch corresponds to kernel version 2.6.16, which you can download here.

叫思念不要吵 2024-08-22 20:02:35

一种判断方法是让它运行,暂停它,然后采取 所有线程的随机堆栈快照。然后再做几次。那么,以锁定代码终止的堆栈样本的比例就是您之后的大致时间百分比。它还会告诉您在哪些位置执行锁定。如果您追求准确性,请采集更多样本。这适用于任何语言或操作系统。

One way to tell is just get it running, pause it, and take a random stackshot of all the threads. Then do it again, several times. Then the fraction of stack samples that terminate in locking code is the percent of time you are after, roughly. It will also tell you which locations the locking is performed in. If you're after accuracy, take more samples. This works in any language or operating system.

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