gperftools-2.5.93

本文介绍如何使用gPerfTools进行CPU性能剖析,包括安装依赖库、设置环境变量及控制信号来启动和停止性能剖析等功能。同时,还介绍了如何在代码中手动控制性能剖析的开始和结束。


https://github.com/gperftools/gperftools


https://gperftools.github.io/gperftools/cpuprofile.html



yum install libunwind

yum install libunwind-devel

yum install graphviz


编译时 -lprofiler 运行找不到 profiler 时,export LD_LIBRARY_PATH=/usr/local/lib/ 默认装这下面


Running the Code

There are several alternatives to actually turn on CPU profiling for a given run of an executable:

  1. Define the environment variable CPUPROFILE to the filename to dump the profile to. For instance, if you had a version of /bin/ls that had been linked against libprofiler, you could run:

    % env CPUPROFILE=ls.prof /bin/ls
  2. In addition to defining the environment variable CPUPROFILE you can also define CPUPROFILESIGNAL. This allows profiling to be controlled via the signal number that you specify. The signal number must be unused by the program under normal operation. Internally it acts as a switch, triggered by the signal, which is off by default. For instance, if you had a copy of /bin/chrome that had been been linked against libprofiler, you could run:

    % env CPUPROFILE=chrome.prof CPUPROFILESIGNAL=12 /bin/chrome &

    You can then trigger profiling to start:

    % killall -12 chrome

    Then after a period of time you can tell it to stop which will generate the profile:

    % killall -12 chrome
  3. In your code, bracket the code you want profiled in calls to ProfilerStart() and ProfilerStop(). (These functions are declared in <gperftools/profiler.h>.) ProfilerStart() will take the profile-filename as an argument.



分析:

pprof  ./demo my.prof > profile.txt

pprof --text ./demo my.prof > profile.txt

pprof --pdf ./demo my.prof > profile.pdf

Error downloading packages: iscsi-initiator-utils-iscsiuio-6.2.0.874-11.el7.x86_64: [Errno 256] No more mirrors to try. glusterfs-client-xlators-3.12.2-47.2.el7.x86_64: [Errno 256] No more mirrors to try. python-rtslib-2.1.fb69-3.el7.noarch: [Errno 256] No more mirrors to try. libibverbs-22.1-3.el7.x86_64: [Errno 256] No more mirrors to try. gnutls-3.3.29-9.el7_6.x86_64: [Errno 256] No more mirrors to try. glusterfs-libs-3.12.2-47.2.el7.x86_64: [Errno 256] No more mirrors to try. glusterfs-3.12.2-47.2.el7.x86_64: [Errno 256] No more mirrors to try. python2-gflags-2.0-5.el7.noarch: [Errno 256] No more mirrors to try. iscsi-initiator-utils-6.2.0.874-11.el7.x86_64: [Errno 256] No more mirrors to try. lttng-ust-2.10.0-1.el7.x86_64: [Errno 256] No more mirrors to try. 1:python2-cinder-14.0.2-2.el7.noarch: [Errno 256] No more mirrors to try. userspace-rcu-0.10.0-3.el7.x86_64: [Errno 256] No more mirrors to try. 10:qemu-img-ev-2.12.0-33.1.el7_7.4.x86_64: [Errno 256] No more mirrors to try. trousers-0.3.14-2.el7.x86_64: [Errno 256] No more mirrors to try. glusterfs-api-3.12.2-47.2.el7.x86_64: [Errno 256] No more mirrors to try. 2:librados2-14.2.1-0.el7.x86_64: [Errno 256] No more mirrors to try. nettle-2.7.1-8.el7.x86_64: [Errno 256] No more mirrors to try. 2:librbd1-14.2.1-0.el7.x86_64: [Errno 256] No more mirrors to try. python2-google-api-client-1.4.2-4.el7.noarch: [Errno 256] No more mirrors to try. gperftools-libs-2.6.1-1.el7.x86_64: [Errno 256] No more mirrors to try. 1:openstack-cinder-14.0.2-2.el7.noarch: [Errno 256] No more mirrors to try. python2-etcd3gw-0.2.4-6.el7.noarch: [Errno 256] No more mirrors to try. python2-oauth2client-1.5.2-3.el7.1.noarch: [Errno 256] No more mirrors to try. python-kmod-0.9-4.el7.x86_64: [Errno 256] No more mirrors to try. librdmacm-22.1-3.el7.x86_64: [Errno 256] No more mirrors to try. python2-uri-templates-0.6-5.el7.noarch: [Errno 256] No more mirrors to try. rdma-core-22.1-3.el7.
最新发布
05-27
### 错误分析 当尝试下载特定的 RPM 包时,如果遇到 `Error downloading RPM packages: [Errno 256] No more mirrors to try` 的错误消息,通常表明系统无法通过配置的镜像源成功获取所需的软件包。这种问题可能是由以下几个原因引起的: 1. **网络连接不稳定**:目标服务器可能暂时不可达或者存在防火墙阻止访问的情况[^1]。 2. **镜像源失效**:某些 CentOS 镜像站点可能会因为维护或其他原因而下线或变得不可用[^2]。 3. **Yum 缓存过期**:本地 Yum 缓存中的元数据可能已经陈旧,未能及时更新到最新的可用镜像列表。 ### 解决方案 以下是几种可以用来解决问题的方法: #### 方法一:更换镜像源 可以通过修改 `/etc/yum.repos.d/CentOS-Base.repo` 文件来切换至更稳定的国内镜像源,比如阿里云、腾讯云等提供的 CentOS 镜像服务。具体操作如下所示: ```bash sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo sudo yum clean all sudo yum makecache ``` #### 方法二:清除并重建缓存 有时清理现有的 Yum 缓存可以帮助解决因缓存文件损坏而导致的问题: ```bash sudo yum clean all sudo yum makecache ``` 这一步会删除所有已有的缓存数据,并重新构建新的索引数据库[^1]。 #### 方法三:手动指定URL安装RPM包 对于个别难以通过官方仓库找到的软件包,可以直接从可信第三方网站(如 rpmfind.net)下载对应的 .rpm 文件再执行离线安装命令: ```bash wget https://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/libarchive-3.1.2-10.el7_2.x86_64.rpm sudo rpm -ivh libarchive-3.1.2-10.el7_2.x86_64.rpm ``` 注意替换实际需要处理的目标程序名称及其版本号[^2]。 #### 方法四:启用调试模式排查细节 开启详细的日志记录有助于定位确切失败环节所在位置,在终端运行下面这条指令即可激活额外的信息输出功能: ```bash yum --verbose install package_name ``` ### 总结 以上四种方式分别针对不同层面进行了探讨,建议按照顺序逐一试验直至恢复正常为止。同时也要记得定期检查系统的安全补丁状态以及保持基础环境处于最新稳定版之上以免遭遇不必要的兼容性冲突情况发生。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值