@@ -15,9 +15,9 @@ information about the performance of your application.
15
15
that aid with the analysis of the data that it produces.
16
16
17
17
The main problem with using the ``perf `` profiler with Python applications is that
18
- ``perf `` only allows to get information about native symbols, this is, the names of
19
- the functions and procedures written in C. This means that the names and file names
20
- of the Python functions in your code will not appear in the output of the ``perf ``.
18
+ ``perf `` only gets information about native symbols, that is, the names of
19
+ functions and procedures written in C. This means that the names and file names
20
+ of Python functions in your code will not appear in the output of ``perf ``.
21
21
22
22
Since Python 3.12, the interpreter can run in a special mode that allows Python
23
23
functions to appear in the output of the ``perf `` profiler. When this mode is
@@ -28,8 +28,8 @@ relationship between this piece of code and the associated Python function using
28
28
29
29
.. note ::
30
30
31
- Support for the ``perf `` profiler is only currently available for Linux on
32
- selected architectures. Check the output of the configure build step or
31
+ Support for the ``perf `` profiler is currently only available for Linux on
32
+ select architectures. Check the output of the `` configure `` build step or
33
33
check the output of ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE ``
34
34
to see if your system is supported.
35
35
@@ -52,11 +52,11 @@ For example, consider the following script:
52
52
if __name__ == " __main__" :
53
53
baz(1000000 )
54
54
55
- We can run ``perf `` to sample CPU stack traces at 9999 Hertz ::
55
+ We can run ``perf `` to sample CPU stack traces at 9999 hertz ::
56
56
57
57
$ perf record -F 9999 -g -o perf.data python my_script.py
58
58
59
- Then we can use ``perf `` report to analyze the data:
59
+ Then we can use ``perf report `` to analyze the data:
60
60
61
61
.. code-block :: shell-session
62
62
@@ -97,7 +97,7 @@ Then we can use ``perf`` report to analyze the data:
97
97
| | | | | |--2.97%--_PyObject_Malloc
98
98
...
99
99
100
- As you can see here , the Python functions are not shown in the output, only ``_Py_Eval_EvalFrameDefault `` appears
100
+ As you can see, the Python functions are not shown in the output, only ``_Py_Eval_EvalFrameDefault ``
101
101
(the function that evaluates the Python bytecode) shows up. Unfortunately that's not very useful because all Python
102
102
functions use the same C function to evaluate bytecode so we cannot know which Python function corresponds to which
103
103
bytecode-evaluating function.
@@ -151,7 +151,7 @@ Instead, if we run the same experiment with ``perf`` support enabled we get:
151
151
How to enable ``perf `` profiling support
152
152
----------------------------------------
153
153
154
- ``perf `` profiling support can either be enabled from the start using
154
+ ``perf `` profiling support can be enabled either from the start using
155
155
the environment variable :envvar: `PYTHONPERFSUPPORT ` or the
156
156
:option: `-X perf <-X> ` option,
157
157
or dynamically using :func: `sys.activate_stack_trampoline ` and
@@ -192,7 +192,7 @@ Example, using the :mod:`sys` APIs in file :file:`example.py`:
192
192
How to obtain the best results
193
193
------------------------------
194
194
195
- For the best results, Python should be compiled with
195
+ For best results, Python should be compiled with
196
196
``CFLAGS="-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" `` as this allows
197
197
profilers to unwind using only the frame pointer and not on DWARF debug
198
198
information. This is because as the code that is interposed to allow ``perf ``
0 commit comments