Skip to content

Conversation

@Yashp002
Copy link
Contributor

@Yashp002Yashp002 commented Jan 6, 2026

gh-141004: Document unstable perf map functions in ceval.h

This PR documents the PyUnstable_CopyPerfMapFile, PyUnstable_PerfTrampoline_CompileCode, and PyUnstable_PerfTrampoline_SetPersistAfterFork functions in Doc/c-api/perfmaps.rst.


📚 Documentation preview 📚: https://cpython-previews--143492.org.readthedocs.build/

.. versionadded:: 3.12
.. c:macro:: PyUnstable_EXECUTABLE_KIND_SKIP

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You used the branch from the other PR, please remove these changes here.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm so sorry yes, fixing rn.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope it's not an issue if i force push a new branch over this one to fix my error?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, avoid them, in this case I think it is fine to remove the changes.

.. c:function:: int PyUnstable_CopyPerfMapFile(const char *parent_filename)
Open the ``/tmp/perf-$pid.map`` file and append the content of *parent_filename*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should note what happens on Windows where this obviously won't work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the case for all of these functions; the info should be in the beginning of the section.

This doesn't open the perf map file directly; it should use the same wording as PyUnstable_WritePerfMapEntry: “Will call :c:func:PyUnstable_PerfMapState_Init…”

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@encukou Would this wording be suitable then as a replacement for line 56 as:

"Calls :c:func:PyUnstable_PerfMapState_Init if the perf map is not yet
initialized, then append the content of parent_filename to the perf map."

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@encukou or @StanFromIreland Could you verify this one too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say only “Append contents of the file named parent_filename to the perf map.” in the opening paragraph, and add the note about _Init later (like in WritePerfMapEntry docs).

Open the ``/tmp/perf-$pid.map`` file and append the content of *parent_filename*
to it.
:param parent_filename: The name of the file to copy.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use these (:param *: & :return:), like above use sentences.

.. c:function:: int PyUnstable_CopyPerfMapFile(const char *parent_filename)
Open the ``/tmp/perf-$pid.map`` file and append the content of *parent_filename*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say only “Append contents of the file named parent_filename to the perf map.” in the opening paragraph, and add the note about _Init later (like in WritePerfMapEntry docs).

.. c:function:: int PyUnstable_PerfTrampoline_CompileCode(PyCodeObject *code)
Compile the given code object using the current perf trampoline.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the perf trampoline? How do you set the current one? What happens if there's no current trampoline?

.. c:function::intPyUnstable_PerfTrampoline_SetPersistAfterFork(int enable)
Set whether the perf trampoline should persist after a fork.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't very clear to me; could you add/link more explanation about the behaviour on fork?

Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update Tools/check-c-api-docs/ignored_c_api.txt as well.

@Yashp002
Copy link
ContributorAuthor

@encukou , @ZeroIntensity

Docs unrelated to test failure

Tests / Windows (free-threading) / Build and test (arm64) (pull_request),Failing after 24m:

testexternalinspection.testcacheperthreadisolation fails in free-threading
ARM64 Windows CI (pre-existing).

@Yashp002
Copy link
ContributorAuthor

@encukou@StanFromIreland
Could you guide me if there are further changes needed with this PR?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core reviewdocsDocumentation in the Doc dirskip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants

@Yashp002@encukou@ZeroIntensity@StanFromIreland