[Python-Dev] Support for Linux perf

Jonas Wagner jonas.wagner at epfl.ch
Sat Nov 22 00:13:00 CET 2014


Hi,

Anyway, I think we must change CPython to support tools such as perf. Any
> thoughts?
>

Not many thoughts, other than that it would be nice to be able to use a
sampling profiler on Python code. I think this would especially benefit
applications that use libraries written in C, or applications that call
external commands. It would also be useful if you're interested in other
metrics than time (e.g., page faults).

Python does have support for profiling, though, in the cProfile module.

The cleanest solution for this might be to add some sort of plugin support
to Perf. Each plugin could teach Perf how to unwind a certain stack. I'm
thinking this because the problem is not specific to Python. Any
higher-level language would benefit from mapping the low-level instruction
pointer and C stack back to higher-level function calls. Databases might
use something like this to individual transactions or compiled SQL
queries...

These plugins would be quite closely tied to a particular interpreter
implementation. You only want them in certain circumstances, and it should
be possible to turn them off, e.g., when you want to profile the
interpreter itself.

On the other hand, this strays somewhat far from what Perf was designed
for. Maybe a custom stack walker could be more easily implemented in
something like SystemTap.

Best,
Jonas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20141122/f6d550df/attachment.html>


More information about the Python-Dev mailing list