Skip to content

Commit 78b6bb9

Browse files
[3.13] gh-141004: Document unstable perf map functions in ceval.h (GH-143492) (GH-153996)
(cherry picked from commit 6453065) Co-authored-by: Yashraj <yashrajpala8@gmail.com>
1 parent 0bb879c commit 78b6bb9

2 files changed

Lines changed: 47 additions & 14 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 the Global Interpreter Lock (GIL) is not required for these AP
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

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,6 @@ PyWrapperFlag_KEYWORDS
6060
PyFile_NewStdPrinter
6161
PyStdPrinter_Type
6262
Py_UniversalNewlineFgets
63-
# cpython/setobject.h
64-
PySet_MINSIZE
65-
# cpython/ceval.h
66-
PyUnstable_CopyPerfMapFile
67-
PyUnstable_PerfTrampoline_CompileCode
68-
PyUnstable_PerfTrampoline_SetPersistAfterFork
69-
# cpython/genobject.h
70-
PyAsyncGenASend_CheckExact
71-
# cpython/longintrepr.h
72-
PyLong_BASE
73-
PyLong_MASK
74-
PyLong_SHIFT
75-
# cpython/pyerrors.h
76-
PyException_HEAD
7763
# cpython/pyframe.h
7864
PyUnstable_EXECUTABLE_KINDS
7965
PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION
@@ -142,3 +128,10 @@ PyUnicode_IS_READY
142128
PYTHON_ABI_VERSION
143129
PySequence_In
144130
PYOS_STACK_MARGIN
131+
# Soft-deprecated in 3.14; will remain undocumented in 3.13
132+
PySet_MINSIZE
133+
PyAsyncGenASend_CheckExact
134+
PyLong_BASE
135+
PyLong_MASK
136+
PyLong_SHIFT
137+
PyException_HEAD

0 commit comments

Comments
 (0)