Skip to content

Commit 27c5953

Browse files
[3.14] gh-141004: Document unstable perf map functions in ceval.h (GH-143492) (GH-153994)
(cherry picked from commit 6453065) Co-authored-by: Yashraj <yashrajpala8@gmail.com>
1 parent 6c225e0 commit 27c5953

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Doc/c-api/perfmaps.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,43 @@ Note that holding an :term:`attached thread state` is not required for these API
4848
This is called by the runtime itself during interpreter shut-down. In
4949
general, there shouldn't be a reason to explicitly call this, except to
5050
handle specific scenarios such as forking.
51+
52+
.. c:function:: int PyUnstable_CopyPerfMapFile(const char *parent_filename)
53+
54+
Open the ``/tmp/perf-$pid.map`` file and append the content of *parent_filename*
55+
to it.
56+
57+
This function is available on all platforms but only generates output on platforms
58+
that support perf maps (currently only Linux). On other platforms, it does nothing.
59+
60+
.. versionadded:: 3.13
61+
62+
.. c:function:: int PyUnstable_PerfTrampoline_CompileCode(PyCodeObject *code)
63+
64+
Compile the given code object using the current perf trampoline.
65+
66+
The "current" trampoline is the one set by the runtime or the most recent
67+
:c:func:`PyUnstable_PerfTrampoline_SetPersistAfterFork` call.
68+
69+
If no trampoline is set, falls back to normal compilation (no perf map entry).
70+
71+
:param code: The code object to compile.
72+
:return: 0 on success, -1 on failure.
73+
74+
.. versionadded:: 3.13
75+
76+
.. c:function:: int PyUnstable_PerfTrampoline_SetPersistAfterFork(int enable)
77+
78+
Set whether the perf trampoline should persist after a fork.
79+
80+
* If ``enable`` is true (non-zero): perf map file remains open/valid post-fork.
81+
Child process inherits all existing perf map entries.
82+
* If ``enable`` is false (zero): perf map closes post-fork.
83+
Child process gets empty perf map.
84+
85+
Default: false (clears on fork).
86+
87+
:param enable: 1 to enable, 0 to disable.
88+
:return: 0 on success, -1 on failure.
89+
90+
.. versionadded:: 3.13

0 commit comments

Comments
 (0)