Content-Length: 390934 | pFad | http://github.com/python/cpython/pull/136461/commits/a7b043da1e8155073176c85fd0113b6e5fe9b08f

10 gh-136459: Add perf trampoline support for macOS by canova · Pull Request #136461 · python/cpython · GitHub
Skip to content

gh-136459: Add perf trampoline support for macOS #136461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 22, 2025
Prev Previous commit
Next Next commit
Apply documentation suggestions from code review
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
  • Loading branch information
canova and hugovk committed Jul 17, 2025
commit a7b043da1e8155073176c85fd0113b6e5fe9b08f
2 changes: 1 addition & 1 deletion Doc/c-api/perfmaps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Support for Perf Maps
----------------------

On supported platforms (as of this writing, Linux and macOS), the runtime can take
On supported platforms (Linux and macOS), the runtime can take
advantage of *perf map files* to make Python functions visible to an external
profiling tool (such as `perf <https://perf.wiki.kernel.org/index.php/Main_Page>`_ or
`samply <https://github.com/mstange/samply/>`_). A running process may create a
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a shameless plug to samply 😄 Disclaimer: I'm not the maintainer of the project, but the maintainer is my colleague. But it doesn't change the fact that it's an awesome profiler! But I can revert it if you prefer not to include :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy with the plug, but this docs are going to need much more than this then. If samply is the main way to use this on macOS then we will need to update https://docs.python.org/3/howto/perf_profiling.html with full instructions for samply :)

Expand Down
18 changes: 9 additions & 9 deletions Doc/howto/perf_profiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ relationship between this piece of code and the associated Python function using
.. note::

Support for profiling is available on Linux and macOS on select architectures.
``perf`` is available on Linux, while ``samply`` can be used on both Linux and macOS.
``samply`` support on macOS is available starting from Python 3.14.
Perf is available on Linux, while samply can be used on both Linux and macOS.
samply support on macOS is available starting from Python 3.14.
Check the output of the ``configure`` build step or
check the output of ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE``
to see if your system is supported.
Expand Down Expand Up @@ -149,25 +149,25 @@ Instead, if we run the same experiment with ``perf`` support enabled we get:



Using ``samply`` profiler
Using the samply profiler
-------------------------

``samply`` is a modern profiler that can be used as an alternative to ``perf``.
samply is a modern profiler that can be used as an alternative to perf.
It uses the same perf map files that Python generates, making it compatible
with Python's profiling support. ``samply`` is particularly useful on macOS
where ``perf`` is not available.
with Python's profiling support. samply is particularly useful on macOS
where perf is not available.

To use ``samply`` with Python, first install it following the instructions at
To use samply with Python, first install it following the instructions at
https://github.com/mstange/samply, then run::

$ samply record PYTHONPERFSUPPORT=1 python my_script.py

This will open a web interface where you can analyze the profiling data
interactively. The advantage of ``samply`` is that it provides a modern
interactively. The advantage of samply is that it provides a modern
web-based interface for analyzing profiling data and works on both Linux
and macOS.

On macOS, ``samply`` support requires Python 3.14 or later.
On macOS, samply support requires Python 3.14 or later.

How to enable ``perf`` profiling support
----------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Add support for perf trampoline on macOS, to allow profilers wit JIT map
support to read python calls. While profiling, ``PYTHONPERFSUPPORT=1`` can
support to read Python calls. While profiling, ``PYTHONPERFSUPPORT=1`` can
be appended to enable the trampoline.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/pull/136461/commits/a7b043da1e8155073176c85fd0113b6e5fe9b08f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy