Skip to content

Commit 0f08c55

Browse files
[3.15] gh-141004: Document unstable perf map functions in ceval.h (GH-143492) (GH-150849)
gh-141004: Document unstable perf map functions in `ceval.h` (GH-143492) (cherry picked from commit 6453065) Co-authored-by: Yashraj <yashrajpala8@gmail.com>
1 parent c69521f commit 0f08c55

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

Doc/c-api/perfmaps.rst

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

Tools/check-c-api-docs/ignored_c_api.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ PyDescr_TYPE
4343
PyWrapperFlag_KEYWORDS
4444
# cpython/fileobject.h
4545
Py_UniversalNewlineFgets
46-
# cpython/ceval.h
47-
PyUnstable_CopyPerfMapFile
48-
PyUnstable_PerfTrampoline_CompileCode
49-
PyUnstable_PerfTrampoline_SetPersistAfterFork
5046
# cpython/pyframe.h
5147
PyUnstable_EXECUTABLE_KINDS
5248
PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION

0 commit comments

Comments
 (0)