简体   繁体   English

linux perf报告行为不一致

[英]linux perf report inconsistent behavior

I have an application I'm profiling using perf and I find the results when using perf report are not consistent, and I can't discern the pattern. 我有我使用分析应用程序的perf和使用时,我发现结果perf report并不一致,我不能辨别的模式。

I start the application and profile it by pid for 60 seconds: 我启动该应用程序,并通过pid对其进行了配置60秒钟:

perf record -p <pid> -o <file> sleep 60

And when I pull the results in with perf report -i <file> , sometimes I see a "+" in the far left column that allows me to drill down into the function call trees when I press ENTER, and sometimes that "+" is not there. 当我用性能perf report -i <file>提取结果时,有时我在最左列看到一个“ +”,当我按ENTER键时,它可以使我深入到函数调用树中,有时还可以看到“ +”不在这里。 It seems to be dependent on some property of the recorded file, in that I have a collection of recorded files, some which allow this drill down and some which do not. 它似乎取决于记录文件的某些属性,因为我有一个记录文件的集合,一些文件允许进行向下钻取,而有些文件则不允许。

Any suggestions on how to get consistent behavior here would be appreciated. 在这里如何获得一致的行为的任何建议将不胜感激。

The default event being measured by perf record is cpu-cycles. 性能记录记录的默认事件是cpu-cycles。 (Or depending on the machine, sometimes cpu-cycles:p or cpu-cycles:pp) (或者取决于机器,有时是cpu-cycles:p或cpu-cycles:pp)

Are you sure your application is not sleeping a lot? 您确定您的应用程序没有睡很多吗? Does it consume a lot of cpu cycles? 它会消耗很多cpu周期吗?

Try a perf measurement on something that stresses the CPU by doing a lot of computations: 通过执行大量计算,在对CPU造成压力的事物上进行性能测量:

$ apt-get install stress
$ perf record -e cpu-cycles --call-graph fp stress --cpu 1 --timeout 5
$ perf report

Subsequent runs should then show more or less similar results. 然后,后续运行应显示或多或少相似的结果。

In case your program is CPU intensive, and call stacks do differ a lot between runs, then you may want to look at the --call-graph option, as perf can record call-graphs with different methods: 如果您的程序占用大量CPU,并且两次运行之间的调用堆栈确实相差很大,那么您可能需要查看--call-graph选项,因为perf可以使用不同的方法记录调用图:

  • fp (function pointer) fp(函数指针)
  • lbr (last branch record) lbr(上一个分支记录)
  • dwarf 侏儒

Maybe different methods give better results. 也许不同的方法会带来更好的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM