openrestry 火焰图

3 篇文章 0 订阅

1. 安装前的准备

  • 1.1 确定/etc/yum.repos.d/CentOS-Debuginfo.repo是否存在.

如果不存在,则创建,并写入如下内容

# CentOS-Debug.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#

# All debug packages from all the various CentOS-7 releases
# are merged into a single repo, split by BaseArch
#
# Note: packages in the debuginfo repo are currently not signed
#

[base-debuginfo]
name=CentOS-7 - Debuginfo
baseurl=http://debuginfo.centos.org/7/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7
enabled=1
#

  • 1.2 创建完成之后,执行下面命令安装
yum makecache
yum --enablerepo=base-debuginfo makecache
yum --enablerepo=base-debuginfo install -y kernel-debuginfo-$(uname -r)
yum install kernel-devel

2. 安装SystemTAP依赖的内核模块

  • 运行下面命令stap-prep,防止以后遗漏依赖的RPM:

  • 检查工作状态, 执行 sudo stap -v -e ‘probe vfs.read {printf(“read performed\n”); exit()}’

Pass 1: parsed user script and 112 library script(s) using 206696virt/34388res/3172shr/31636data kb, in 150usr/10sys/160real ms.
Pass 2: analyzed script: 1 probe(s), 1 function(s), 4 embed(s), 0 global(s) using 303176virt/131936res/4196shr/128116data kb, in 810usr/170sys/985real ms.
Pass 3: using cached /root/.systemtap/cache/8c/stap_8c663b631dd63f195036468facfcc2d2_1625.c
Pass 4: using cached /root/.systemtap/cache/8c/stap_8c663b631dd63f195036468facfcc2d2_1625.ko
Pass 5: starting run.
read performed
Pass 5: run completed in 0usr/10sys/353real ms.

3. 安装SystemTAP

yum install -y systemtap systemtap-runtime

4. 源码编译OpenResty

  • 编译过程如下, 切记添加 "CCDEBUG=-g"
sudo make CCDEBUG=-g
sudo make install

5.开始抓取数据

sudo ./ngx-sample-lua-bt  -p 19674 -t 60 --luajit20 > a.bt

6. 生成火焰图

sudo ./stackcollapse-stap.pl a.bt > a.cbt
sudo ./flamegraph.pl a.cbt > a.svg
  • 用浏览器打开 a.svg,就可以看到效果了

在这里插入图片描述

火焰图的内容参考:

  1. 如何读懂火焰图
  2. 火焰图性能分析
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值