我有一个应用程序,我想分析在各种活动中花费了多少时间。由于此应用程序是 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!
发布评论
评论(3)
从此提交来看,最近发布的 strace 4.9 支持这一点:
他们称之为“系统调用延迟”(仅从手册页很难看出这就是
-w
的作用)。Judging from this commit, the recently released strace 4.9 supports this with:
They call it "syscall latency" (and it's hard to see from the manpage alone that's what
-w
does).您这样做只是出于对测量的好奇心,还是因为您想找到可以修复的时间消耗以使其运行得更快?
如果您的目标是使其运行得尽可能快,那么 尝试随机暂停。
除了非常粗略地测量之外,它不测量任何东西。
这可能是违反直觉的,但它所做的是精确定位将导致最大加速的代码。
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.
请参阅
fntimes.stp
systemtap 示例脚本。 https://sourceware.org/systemtap/examples/index.html#profiling /fntimes.stpfntimes.stp 脚本监视给定函数系列(假定非递归)的执行时间历史记录。然后将每次(超出预热间隔)与历史最大值进行比较。如果超过特定阈值 (250%),则会打印一条消息。
或
.stp 脚本的最后一行演示了跟踪给定函数系列中消耗的时间的方法
See the
fntimes.stp
systemtap sample script. https://sourceware.org/systemtap/examples/index.html#profiling/fntimes.stpThe 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.
or
The last line of that .stp script demonstrates the way to track time consumed in a given family of functions