TCmalloc CPUPROFILE没有输出

发布于 2025-01-14 02:39:06 字数 1472 浏览 4 评论 0原文

我目前对谷歌的用户级内存分配器和TCmalloc感兴趣。

我看到页面显示了对比较 PTmalloc2 和 TCmalloc 的一些评估。

我想在我的环境中重建那个实验。

因此,我从此处的官方参考安装了 TCmalloc。

并安装 golang 以使用名为“pprof”的分析工具 然后,到这个命令

sudo snap install --classic go 

,安装上面的命令 google-pprof 工具

go install github.com/google/pprof@latest

,从 这里

最后,我刚刚测试了 TCmalloc Tensorflow MNIST python 代码使用LD_PRELOAD

   LD_PRELOAD=/usr/lib/libtcmalloc.so.4 python3 MNIST.py

它有效。

生成的堆配置文件二进制(.heap)

LD_PRELOAD=/usr/lib/libtcmallo.so.4 HEAPPROFILE=log python3 MNIST.py

也有效。

生成的 .heap 文件

使用 google-pprof 进行分析也可以。

并尝试使用下面的代码 CPUPROFILE

LD_PRELOAD=/usr/lib/libtcmallo.so.4 CPUPROFILE=cpu python3 MNIST.py

它不起作用。没有输出。

我缺少什么?

-我的系统-

Ubuntu 20.04.1LTS x86-64 5.13.0-35

gcc/g++: 9.4.0

CPU: Intel i9-12900KF

内存: 32GB

感谢您的关注。

我期待任何回复。

I am currently interested in user-level memory allocator and TCmalloc from google.

I saw this page that shows some evaluation to comparing PTmalloc2 and TCmalloc.

I want to rebuild that experiment in my environment.

So, I installed TCmalloc from an official reference from here.

and also install golang for using profiling tool that called 'pprof'
to this command

sudo snap install --classic go 

then, install google-pprof tools

go install github.com/google/pprof@latest

above command get from here

finally, I just tested TCmalloc with Tensorflow MNIST python code using LD_PRELOAD

   LD_PRELOAD=/usr/lib/libtcmalloc.so.4 python3 MNIST.py

It works.

And Generated heap profile binary(.heap)

LD_PRELOAD=/usr/lib/libtcmallo.so.4 HEAPPROFILE=log python3 MNIST.py

It works too.

generated .heap file

Analyzing by using google-pprof also works.

And tried CPUPROFILE with under code

LD_PRELOAD=/usr/lib/libtcmallo.so.4 CPUPROFILE=cpu python3 MNIST.py

It didn't work. There is no output.

What am I missing?

-my system-

Ubuntu 20.04.1LTS x86-64
5.13.0-35

gcc/g++: 9.4.0

CPU: Intel i9-12900KF

MEMORY: 32GB

Thanks for your attention.

I’m looking forward to any reply.

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

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

发布评论

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

评论(1

此刻的回忆 2025-01-21 02:39:06

我从这个网站找到了我错过的东西!

可执行文件必须通过 -lprofiler 选项链接。

然后,我使用 LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtprofiler.so 来挂钩

共享库而无需构建。

整个命令

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so:/usr/lib/x86_64-linux-gnu/libprofiler.so CPUPROFILE=tcmalloc_python.prof python3 MNIST.py

(使用多个库时必须用:(冒号)分隔)

如果遇到“ERROR: ld.so: LD_PRELOAD 中的对象“libpath”无法预加载(无法打开共享对象文件):已忽略”消息,该路径中一定不存在库文件。

因此,只需以另一种方式重新安装 pprof 即可。

尝试

sudo apt install google-pprof-dev 

sudo apt-get install golang-github-google-pprof-dev

然后重试上述命令(LD_PRELOAD~)。它会起作用的。

引用自此处

就我而言,它有效。

训练完成后,会生成一些.prof文件!

结果

但是,pprof 不适用于 python 代码(仅 c/c++ 可执行文件)

我会另寻办法。 (有什么想法吗?)

pprof 结果

所以,我从这里找到了一些测试代码并构建了一个可执行文件文件。

然后尝试了pprof,它有效! (pprof 手册

pprof 结果(成功)

I found what I missed from This site!

The executable file must link by the -lprofiler option.

Then, I used LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtprofiler.so for hooking

a shared library without build.

Entire command

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so:/usr/lib/x86_64-linux-gnu/libprofiler.so CPUPROFILE=tcmalloc_python.prof python3 MNIST.py

(You must separate with :(colon) when using multiple libraries)

If you meet "ERROR: ld.so: object 'libpath' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored" message, that must be don't exist library file in that path.

So, just reinstall pprof another way.

try

sudo apt install google-pprof-dev 

or

sudo apt-get install golang-github-google-pprof-dev

and then, retry the above command(LD_PRELOAD~). It will work.

Referenced from here.

In my case, it works.

After training is done, some .prof file is generated!

result

But, pprof didn't work at python code(only c/c++ executable file)

I'll find another way. (Any idea?)

pprof result

So, I found some test code from here and build an executable file.

Then tried pprof, It works! (pprof manual)

pprof result (success)

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