Skip to content

Conversation

mstange
Copy link
Owner

@mstange mstange commented Sep 27, 2024

Python has support for perf JIT maps. It prefixes the python function names with "py::": https://github.com/python/cpython/blob/4b89c5ebfc7d5d4f008eee0ae6da765dfc28e3a9/Python/perf_trampoline.c#L218

To use this, on Linux, build python 3.12 with frame pointers enabled, and run your python script with the PYTHONPERFSUPPORT=1 environment variable set:

CFLAGS="-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" pyenv install 3.12
pyenv shell 3.12
samply record PYTHONPERFSUPPORT=1 python stuff.py

Python has support for perf JIT maps. It prefixes the python function names with "py::":
https://github.com/python/cpython/blob/4b89c5ebfc7d5d4f008eee0ae6da765dfc28e3a9/Python/perf_trampoline.c#L218

To use this, on Linux, build python 3.12 with frame pointers enabled, and run
your python script with the `PYTHONPERFSUPPORT=1` environment variable set:

```
CFLAGS="-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" pyenv install 3.12
pyenv shell 3.12
samply record PYTHONPERFSUPPORT=1 python stuff.py
```
@mstange mstange merged commit bae59e5 into main Sep 27, 2024
15 checks passed
@ngoldbaum
Copy link

This is extremely useful, thanks for adding this!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants