Linux 上的 wall-time 分析

发布于 2024-11-18 15:21:23 字数 334 浏览 3 评论 0 原文

我有一个应用程序,我想分析在各种活动中花费了多少时间。由于此应用程序是 I/O 密集型,因此我希望获得一份报告,该报告将总结每个库/系统调用所花费的时间(挂起时间)。

我尝试过 oprofile,但它似乎给出了未停止的 CPU 周期的时间(即 cputime,而不是实时)

我尝试过 strace -T,它给出了 wall time,但生成的数据很大并获取摘要报告很难(并且存在 awk/py 脚本吗?)

现在我正在查找 SystemTap,但我没有找到任何足够接近且可以修改的脚本,并且现场教程也没有多大帮助。我不确定我正在寻找的东西是否可以实现。

我需要有人为我指明正确的方向。 多谢!

I have an application that I want to profile wrt how much time is spent in various activities. Since this application is I/O intensive, I want to get a report that will summarize how much time is spent in every library/system call (wall time).

I've tried oprofile, but it seems it gives time in terms of Unhalted CPU cycles (thats cputime, not real time)

I've tried strace -T, which gives wall time, but the data generated is huge and getting the summary report is difficult (and awk/py scripts exist for this ?)

Now I'm looking upto SystemTap, but I don't find any script that is close enough and can be modified, and the onsite tutorial didn't help much either. I am not sure if what I am looking for can be done.

I need someone to point me in the right direction.
Thanks a lot!

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

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

发布评论

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

评论(3

时光磨忆 2024-11-25 15:21:23

此提交来看,最近发布的 strace 4.9 支持这一点:

strace -w -c

他们称之为“系统调用延迟”(仅从手册页很难看出这就是 -w 的作用)。

Judging from this commit, the recently released strace 4.9 supports this with:

strace -w -c

They call it "syscall latency" (and it's hard to see from the manpage alone that's what -w does).

神经暖 2024-11-25 15:21:23

您这样做只是出于对测量的好奇心,还是因为您想找到可以修复的时间消耗以使其运行得更快?

如果您的目标是使其运行得尽可能快,那么 尝试随机暂停
除了非常粗略地测量之外,它不测量任何东西。
这可能是违反直觉的,但它所做的是精确定位将导致最大加速的代码。

Are you doing this just out of measurement curiosity, or because you want to find time-drains that you can fix to make it run faster?

If your goal is to make it run as fast as possible, then try random-pausing.
It doesn't measure anything, except very roughly.
It may be counter-intuitive, but what it does is pinpoint the code that will result in the greatest speed-up.

不语却知心 2024-11-25 15:21:23

请参阅 fntimes.stp systemtap 示例脚本。 https://sourceware.org/systemtap/examples/index.html#profiling /fntimes.stp

fntimes.stp 脚本监视给定函数系列(假定非递归)的执行时间历史记录。然后将每次(超出预热间隔)与历史最大值进行比较。如果超过特定阈值 (250%),则会打印一条消息。

# stap fntimes.stp 'kernel.function("sys_*")'

# stap fntimes.stp 'process("/path/to/your/binary").function("*")'

.stp 脚本的最后一行演示了跟踪给定函数系列中消耗的时间的方法

probe $1.return { elapsed = gettimeofday_us()-@entry(gettimeofday_us()) }

See the fntimes.stp systemtap sample script. https://sourceware.org/systemtap/examples/index.html#profiling/fntimes.stp

The fntimes.stp script monitors the execution time history of a given function family (assumed non-recursive). Each time (beyond a warmup interval) is then compared to the historical maximum. If it exceeds a certain threshold (250%), a message is printed.

# stap fntimes.stp 'kernel.function("sys_*")'

or

# stap fntimes.stp 'process("/path/to/your/binary").function("*")'

The last line of that .stp script demonstrates the way to track time consumed in a given family of functions

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