一、oprofile的相关链接:oprofile的 manual | 下载 。
二、oprofile的安装使用
2.1 安装
wget http://prdownloads.sourceforge.net/oprofile/oprofile-0.9.7.tar.gz
tar -zxvf oprofile-0.9.7.tar.gz
cd oprofile-0.9.7
sudo yum install binutils-devel --说明:configure报错时候需要装一下这个包 (参考这个网址)
./configure
make
sudo make install
2.2 使用
sudo opcontrol --deinit; sudo /sbin/modprobe oprofile timer=1sudo opcontrol --setup --no-vmlinux && sudo opcontrol --init && sudo opcontrol --reset && sudo opcontrol --start
$mysqlslap --no-defaults --query=" select count(*) as num from vid_film left join vid_class_map on vid_film.id=vid_class_map.v_id and vid_class_map.s_type=1 and vid_class_map.class_id=1;" --number-of-queries=5000 --concurrency=50 -uroot --socket=/u01/mysql/run/mysql.sock
sudo opcontrol --shutdownopreport -g -l -p /u01/mysql /u01/mysql/libexec/mysqld --merge all -o tmp.log
2.3 遇到的问题
(1)使用opreport报错:
1、error: no sample files found: profile specification too strict
2、opreport error: No sample file found: try running opcontrol --dump or specify a session containing sample files
的时候,需要删除下面配置
sudo rm -f /root/.oprofile/daemonrc
参考:http://blog.yufeng.info/archives/1283
(2)报告的结果无具体符号表相关信息
$more tmp.log
CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt
samples % linenr info symbol name
16823 100.000 (no location information) /u01/mysql/libexec/mysqld
问题:这个时候只看到mysqld,看不到线程具体跑的函数统计。通过命令( objdump -t /u01/mysql/libexec/mysqld | head )查看是无符号表。
原因:这个mysql是rpm直接安装的,虽然在configure时候也是有加-g,rpmbuild时候问题
解决:源码重新编译一下,重新跑上面的就OK了,结果如下:
$head -n15 tmp.log
CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt
samples % linenr info symbol name
4589 16.4628 mf_keycache.c:1666 find_key_block
4123 14.7910 mf_keycache.c:2542 key_cache_read
3781 13.5641 my_handler.c:124 ha_key_cmp
3554 12.7498 bmove512.c:40 bmove512
2403 8.6206 mf_keycache.c:1349 unreg_request
2238 8.0287 mi_search.c:184 _mi_bin_search
679 2.4359 mi_search.c:64 _mi_search
618 2.2170 mi_key.c:220 _mi_pack_key
615 2.2063 sql_select.cc:11896 join_read_key(st_join_table*)
469 1.6825 sql_select.cc:11345 sub_select(JOIN*, st_join_table*, bool)
466 1.6717 sql_select.cc:11413 evaluate_join_record(JOIN*, st_join_table*, int)
409 1.4673 mi_key.c:468 _mi_read_key_record
--EOF--
--需要安装 kernel-debuginfo-2.6.18-164.el5.x86_64.rpm kernel-debuginfo-common-2.6.18-164.el5.x86_64.rpm 才能看到
Link | 02月 2nd, 2012 at 13:18
How to install kernel-debug in RHEL-Red Hat/Fedora Linux?
http://joysofprogramming.com/install-kernel-debug-fedora-rhel/
Link | 03月 14th, 2012 at 22:10