Linuxias
Developer's Delight
Linuxias
  • Category
    • AI
      • Deep Learning
      • Machine Learning
      • Data Science
      • Framework
      • MLOps
      • Paper-Review
      • Tips
    • Android
      • Kotlin
      • Component
      • Compose
      • Compose UI
      • Material
      • Testing
    • Software Architecture
      • Architecture Pattern
      • Design Pattern
      • Requirement Engineering
    • Linux
      • Compile & Link
      • Command & Tool
      • Container
      • Debugging & Testing
      • Profiling
      • Kernel Analysis
      • Server
      • Shell Script
      • System Programming
    • Language
      • Carbon
      • C,C++
      • C#
      • Java
      • Python
    • ETC
      • Data Struct | Algorithm
      • git
      • Security
    • Book
    • 경제공부
      • 세금
      • 부동산
hELLO · Designed By 정상우.
Linuxias

Developer's Delight

Linux/Profiling

Process Profiling

2021. 2. 4. 18:27
반응형

1. Perf + FlameGraph

Process의 FlameGraph를 뽑아내는 과정을 설명한다. Perf의 --call-graph 기능을 이용한다.

1) Kernel setting

echo -1 > /proc/sys/kernel/perf_event_paranoid
echo 0 > /proc/sys/kernel/kptr_restrict
chmod a+r /proc/kallsyms
echo 100 > /proc/sys/kernel/perf_cpu_time_max_percent
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

2) Get perf data

perf record -o perf.data --call-graph=dwarf -F 15000 -p {PID}
perf script --max-stack 1024 --input=perf.data -f > out.perf

3) Create FlameGraph

c++filt < out.perf > out.perf_filted
stackcollapse-perf.pl --all out.perf_filted > out.perf_collapsed
flamegraph.pl -color=java --hash out.perf_collapsed > FlameGraph.svg

2. Count function call using gdb

1) Create breakpoint

 break func_name
 ...
 • [23] break number

2) Ignore break point

ignore 23 1000000   # set ignore count very high.

3) Run or Continue

run  # the program will SIGSEGV before reaching the ignore count.
     # Once it stops with SIGSEGV:

4) Show count

info break 23  # tells you how many times the breakpoint has been hit, 
               # which is exactly the count you want
반응형
저작자표시 비영리 (새창열림)

'Linux > Profiling' 카테고리의 다른 글

[Profiling Experience] About Weak / Strong symbol  (0) 2022.01.13
[glibc] malloc, free mechanism  (0) 2021.02.04
Performance Methodologies  (0) 2021.02.04
Memory Profiling  (0) 2021.02.04
[Profiling Tool] LTTng  (0) 2021.02.04
    'Linux/Profiling' 카테고리의 다른 글
    • [Profiling Experience] About Weak / Strong symbol
    • [glibc] malloc, free mechanism
    • Performance Methodologies
    • Memory Profiling
    Linuxias
    Linuxias
    I want to be a S/W developer who benefits people.

    티스토리툴바