哪个分析器更准确:OProfile 还是 Google Performance Tools?

发布于 2024-08-07 06:53:07 字数 289 浏览 2 评论 0原文

我发现了两个很棒的分析器:

有人尝试过这两个工具吗?哪个更好?

I found two great profilers:

Have anyone tried them both? Which is better?

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

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

发布评论

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

评论(1

穿透光 2024-08-14 06:53:07

oprofile更准确;它使用CPU性能监控(内置硬件监控,具有100个性能事件);

并且 google-perftools libprofiler.so 使用 setitimer - 操作系统内核的 intreval 计时器:

$ nm -D libprofiler.so | grep timer
     U getitimer
     U setitimer

间隔计时器由操作系统模拟,并且不能超过 HZ,据我所知(每秒 100 次或每秒 1000 次或 300 或 250)。我刚刚尝试了 10000 和 100000,但有效率为 1000(程序运行时间为 2 秒,并且 cpu profiler 从 google 收集到的样本只有约 2000 个)。这是我的 HZ:

$ zgrep HZ= /proc/config.gz
CONFIG_HZ=1000

不知道这在无滴答内核上如何工作。

反过来,oprofile 使用 CPU 中的特殊硬件,该硬件的精确度可达几个刻度。它可以在 CPU 每 100000 次或 1000000 次滴答时测量程序的位置,并且该值与操作系统 HZ 设置无关。此外,它不仅可以分析 CPU 的每个 N 个周期,还可以分析每个 N 个 L2 缓存未命中或每个 N 个 jmp 错误预测等等......有数百个硬件Pentium Pro 之后的任何 CPU 中的性能事件。

oprofile 的另一个更好的方面是它可以分析任何内容,任何用户应用程序或所有用户应用程序或内核和每个应用程序。

但是 oprofile 需要 root 才能使用它(AFAIK),如果使用错误,它可能会冻结您的系统;它需要在内核中启用(当内核构建时)。

google-perftools 更好的一面是:易于使用;良好的绘图和分析能力;无需 root 即可工作。另外,google-perftools 中有一个很好的堆分析器。

oprofile 和 google-perftools/cpuprofiler:

  • 不需要重新编译应用程序(就像 gprof/gcov 需要的那样)
  • 可以绘制部分调用图(就像在 kcachegind 中完成的那样,例如 1 2;pprof 甚至可以通过 kcachegrind 使用 callgrind 命令进行绘制)
  • 将测量真实的轮廓(而不是像 kcachegrind/callgrind/其他 valgrind 中那样的模拟轮廓)基于)
  • 可移植(oprofile 需要 CPU 的支持,但它适用于 intel/amd/via/manyarms;perftools 将在任何可以获得调用堆栈并要求操作系统安装 setitimer 的地方工作)

oprofile is more accurate; it uses CPU performance monitoring (built in hardware monitoring with 100s of performance events);

and google-perftools libprofiler.so uses setitimer - intreval timer of OS kernel:

$ nm -D libprofiler.so | grep timer
     U getitimer
     U setitimer

Interval timer is emulated by OS and it can't be more than HZ, as I know (100 times per second or 1000 times per second or 300 or 250). I just tried both 10000 and 100000, but the effective rate was 1000 (run time of program is 2 seconds and there is only ~2000 samples collected by cpu profiler from google). This is my HZ:

$ zgrep HZ= /proc/config.gz
CONFIG_HZ=1000

Don't know how this will work on tickless kernel.

In turn, oprofile uses special hardware in CPU and this hardware is accurate up to several ticks. It can measure, where your program is, at every 100000th or 1000000th ticks of CPU and this value is not tied to OS HZ setting. Also it can profile not only on every N-th tick of CPU, but also on every N-th L2 cache miss or every N-th jmp misprediction and so on... there are hundreds of hardware performance events in any CPU after Pentium Pro.

The other better side of oprofile is that it can profile anything, any user application or all user application or kernel and every application.

But oprofile requires root to use it (AFAIK), it can freeze you system with wrong usage; it needs to be enabled in kernel (when kernel was built).

Better side of google-perftools is: easy to use; good graphing and analysing capabilities; need no root to work. Also, there is a good heap profiler in google-perftools.

Both oprofile and google-perftools/cpuprofiler:

  • needs no recompilation of application (like it was needed with gprof/gcov)
  • can draw a partial callgraph (like it is done in kcachegind, e.g. 1 2; pprof even can draw via kcachegrind with callgrind command )
  • will measure real profile (not an emulated one like in kcachegrind/callgrind/ other valgrind-based)
  • portable (oprofile needs support from and for CPU, but it is here for intel/amd/via/ many arms; perftools will work anywhere where it can get callstack and ask OS to install setitimer)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文