Skip to content

Instantly share code, notes, and snippets.

@rakeshcusat
Last active March 24, 2020 19:38
Show Gist options
  • Save rakeshcusat/8c94b6a40e388fb97dfadf16a5217b82 to your computer and use it in GitHub Desktop.
Save rakeshcusat/8c94b6a40e388fb97dfadf16a5217b82 to your computer and use it in GitHub Desktop.
Instructions to attach the pyflame with python process and monitor the performance.
  1. git clone git@github.com:/brendangregg/flamegraph
  2. pick the python worker. based on the following command:
ps -aux | grep python
# or
top -o RES -c

If you know what process you want to monitor just get the pid of the process. 3. Attach the pyflame with the process.

sudo pyflame -s <TIME-WINDOW-IN-SECONDS> -r 0.01 <PROCESS-ID> >> profile.out

  1. Go to the FlameGraph directory to run the FlameGraph script.
cd flamegraph

# in case file is remote then run the following command
scp -r <HOST-NAME>:/home/rakeshkumar/profile.out . 

  1. Run the following command to filter idle time from the data. It will just reduce the noise from the final svg file.
cat profile.out | grep -v idle | ./flamegraph.pl > flamegraph.svg
  1. Open the svg file in a browser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment