Skip to content

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

Merged
ZeroIntensity merged 8 commits into
python:mainfrom
Yashp002:doc-ceval-perf
Jun 3, 2026
Merged

gh-141004: Document unstable perf map functions in ceval.h#143492
ZeroIntensity merged 8 commits into
python:mainfrom
Yashp002:doc-ceval-perf

Conversation

@Yashp002

@Yashp002Yashp002 commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

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/

Comment threadDoc/c-api/frame.rst Outdated
.. versionadded:: 3.12


.. c:macro:: PyUnstable_EXECUTABLE_KIND_SKIP

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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?

Copy link
Copy Markdown
Member

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*

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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).

Comment threadDoc/c-api/perfmaps.rst Outdated
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.

Copy link
Copy Markdown
Member

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
Copy Markdown
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).

Comment threadDoc/c-api/perfmaps.rst
Comment threadDoc/c-api/perfmaps.rst

@ZeroIntensityZeroIntensity left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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

@encukouencukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I asked some more questions. Could you go through the unresolved comments here?

Comment threadDoc/c-api/perfmaps.rst Outdated
Comment on lines +53 to +54
These unstable functions let you access and set perf map information
about the current frame from C code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't make sense to me. What is the connection to the current frame?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

My bad, that text was completely out of place (and wrong). I'm deleting those lines entirely.

Comment threadDoc/c-api/perfmaps.rst Outdated
Comment on lines +56 to +57
Note: Appends the content of the parent frame to the current one in perf maps.
Just like in frameobject.h.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What function(s) is this note for? What is the connection to frameobject.h?

Comment threadDoc/c-api/perfmaps.rst Outdated
Open the ``/tmp/perf-$pid.map`` file and append the content of *parent_filename*
to it.

This function is only available on platforms that support perf maps (currently

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not accurate, the function is "available" on all platforms. But it should only be used on Linux. On Windows, it does nothing (it's not implemented).

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actionsgithub-actionsBot added the stale Stale PR or inactive for long period of time. label May 4, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32971943 | 📁 Comparing ba3e3cf against main (5553e00)

🔍 Preview build

2 files changed
±c-api/perfmaps.html
±whatsnew/changelog.html

@ZeroIntensityZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see any more blocking issues here -- let's get these documented!

If anyone disagrees with anything here, or otherwise want to make some change to the test, feel free to send a follow-up and tag me on it.

@ZeroIntensity
ZeroIntensity enabled auto-merge (squash) June 3, 2026 12:33
@ZeroIntensityZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes and removed stale Stale PR or inactive for long period of time. labels Jun 3, 2026
@ZeroIntensity
ZeroIntensity merged commit 6453065 into python:mainJun 3, 2026
51 checks passed
@github-project-automationgithub-project-automationBot moved this from Todo to Done in Docs PRsJun 3, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @Yashp002 for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app

Copy link
Copy Markdown

Sorry, @Yashp002 and @ZeroIntensity, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 6453065db9ff31e3f737240030f8311d2b087851 3.14

@bedevere-app

Copy link
Copy Markdown

GH-150849 is a backport of this pull request to the 3.15 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 3, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @Yashp002 and @ZeroIntensity, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 6453065db9ff31e3f737240030f8311d2b087851 3.13

ZeroIntensity pushed a commit that referenced this pull request Jun 3, 2026
…H-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>
philthompson10 pushed a commit to philthompson10/cpython that referenced this pull request Jun 17, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member

Please don't forget about backports.

@bedevere-app

Copy link
Copy Markdown

GH-153994 is a backport of this pull request to the 3.14 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.14 bugs and security fixes label Jul 18, 2026
@bedevere-app

Copy link
Copy Markdown

GH-153996 is a backport of this pull request to the 3.13 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.13 bugs and security fixes label Jul 18, 2026
ZeroIntensity added a commit that referenced this pull request Jul 18, 2026
…H-143492) (GH-153996)
(cherry picked from commit 6453065)
Co-authored-by: Yashraj <yashrajpala8@gmail.com>
ZeroIntensity added a commit that referenced this pull request Jul 18, 2026
…H-143492) (GH-153994)
(cherry picked from commit 6453065)
Co-authored-by: Yashraj <yashrajpala8@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docsDocumentation in the Doc dirskip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants

@Yashp002@serhiy-storchaka@vstinner@encukou@ZeroIntensity@StanFromIreland