Skip to content

Instantly share code, notes, and snippets.

@jrmuizel
Created September 27, 2024 17:42
Show Gist options
  • Save jrmuizel/63667a68ccb65ede9346a29c6a29aadc to your computer and use it in GitHub Desktop.
Save jrmuizel/63667a68ccb65ede9346a29c6a29aadc to your computer and use it in GitHub Desktop.
Profiling python with perf

Get a Python that has frame pointers enabled

CFLAGS="-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" pyenv install 3.12
pyenv shell 3.12

Run python with perf support turned on

PYTHONPERFSUPPORT=1 poetry run python merino/main.py
perf record -F 9999 -g -p [pid]
cargo install --git https://github.com/mstange/samply samply --locked --force
samply import perf.data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment