https://perf.wiki.kernel.org/index.php/Tutorial
[root@fc17 ~]# cat /etc/fedora-release Fedora release 17 (Beefy Miracle) [root@fc17 ~]# uname -ri 3.4.0-1.fc17.x86_64 x86_64 |
install perf via yum
[root@fc17 ~]# yum install perf -y |
[ example usage ]
# perf top |
you can see which processes affect linux kernel performance.
you could also see the detail of specific process info.
select a process -> type enter
here’s an output of map details.
- perf record and perf repot
record kernel performance into a file
[root@fc17 ~]# perf record -a sleep 5 [ perf record: Woken up 5 times to write data ] [ perf record: Captured and wrote 2.234 MB perf.data (~97596 samples) ] |
info is written into perf.data file
.
read that data
“perf report” command reads info from perf.data file.
# perf report Events: 14K cycles 12.32% swapper [kernel.kallsyms] [k] native_safe_ha 5.25% dig ld-2.15.so [.] do_lookup_x 2.75% dig ld-2.15.so [.] strcmp 2.37% chrome libflashplayer.so [.] 0x00000000003d 1.75% dig [kernel.kallsyms] [k] clear_page_c 1.66% dig [kernel.kallsyms] [k] page_fault 1.49% dig libc-2.15.so [.] __memset_x86_6 1.38% dig ld-2.15.so [.] _dl_lookup_sym 1.32% gnome-terminal libvte2_90.so.9.3200.1 [.] 0x000000000003 1.20% dig [kernel.kallsyms] [k] unmap_single_v 1.13% dig ld-2.15.so [.] _dl_relocate_o 0.97% gnome-shell r600_dri.so [.] 0x000000000005 |
# perf report --sort=cpu Events: 14K cycles 26.35% 3 25.43% 0 24.50% 1 23.73% 2 |
- monitor a specific process
check PID you want to monitor
[root@fc17 ~]# ps aux | grep unbound | grep -v grep unbound 1772 0.1 0.1 51596 9884 ? Ss 00:23 0:03 unbound -c /etc/unbound/unbound.conf |
[root@fc17 ~]# perf stat -p 1772 sleep 5 Performance counter stats for process id '1772': 2619.300788 task-clock # 0.524 CPUs utilized [100.00%] 2,294 context-switches # 0.876 K/sec [100.00%] 147 CPU-migrations # 0.056 K/sec [100.00%] 252 page-faults # 0.096 K/sec 2,104,000,503 cycles # 0.803 GHz [49.81%] 576,211,571 stalled-cycles-frontend # 27.39% frontend cycles idle [49.55%] 702,855,782 stalled-cycles-backend # 33.41% backend cycles idle [49.55%] 1,512,642,754 instructions # 0.72 insns per cycle # 0.46 stalled cycles per insn [50.19%] 296,171,521 branches # 113.073 M/sec [50.45%] 23,773,996 branch-misses # 8.03% of all branches [50.45%] 5.001789912 seconds time elapsed |
interesting tool.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.