TCmalloc CPUPROFILE没有输出
我目前对谷歌的用户级内存分配器和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
也有效。
使用 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.
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从这个网站找到了我错过的东西!
可执行文件必须通过
-lprofiler
选项链接。然后,我使用 LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtprofiler.so 来挂钩
共享库而无需构建。
整个命令
(使用多个库时必须用
:
(冒号)分隔)如果遇到“ERROR: ld.so: LD_PRELOAD 中的对象“libpath”无法预加载(无法打开共享对象文件):已忽略”消息,该路径中一定不存在库文件。
因此,只需以另一种方式重新安装 pprof 即可。
尝试
或
然后重试上述命令(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 hookinga shared library without build.
Entire command
(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
or
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)