gh-154060: Fix the Profile Stats offsets in the profiling binary format docs and a missing flag - #157871
Open
maurycy wants to merge 2 commits into
Open
gh-154060: Fix the Profile Stats offsets in the profiling binary format docs and a missing flag#157871maurycy wants to merge 2 commits into
Profile Stats offsets in the profiling binary format docs and a missing flag#157871maurycy wants to merge 2 commits into
Conversation
Contributor
Author
|
cc @pablogsal 🖤 |
Profile Stats offsets in the profiling binary format docsProfile Stats offsets in the profiling binary format docs and a missing flag
maurycy
commented
Sep 20, 2026
| | 2 | THREAD_STATUS_UNKNOWN | Thread state could not be determined | | ||
| | 3 | THREAD_STATUS_GIL_REQUESTED | Thread is waiting to acquire the GIL | | ||
| | 4 | THREAD_STATUS_HAS_EXCEPTION | Thread has a pending exception | | ||
| | 5 | THREAD_STATUS_MAIN_THREAD | Thread is the process's main thread | |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| | 5 | THREAD_STATUS_MAIN_THREAD | Thread is the process's main thread | | |
| | 5 | THREAD_STATUS_MAIN_THREAD | Thread is the interpreter's main thread | |
Very formally speaking I think that's the case... I don't know if should expose this, though. Leaving as a suggestion, so the reviewer can just click or resolve.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The file layout diagram in:
https://github.com/python/cpython/blob/a64b7ecba4db5480504a1a83ae6e80c81472fe16/InternalDocs/profiling_binary_format.md#file-layout
says that the
Profile Statssection is 32 bytes and starts atfile_size - 64, while it's 56 bytes and starts atfile_size - 88(56 + 32 = 88).cpython/Modules/_remote_debugging/binary_io.h
Lines 122 to 123 in a64b7ec
cpython/Modules/_remote_debugging/binary_io.h
Lines 91 to 92 in a64b7ec
The test:
cpython/Lib/test/test_profiling/test_sampling_profiler/test_binary_format.py
Lines 1655 to 1660 in a64b7ec
Even the doc itself says 56 bytes later:
Both the diagram and the section is since 7f0ccd6.
While we're at it, adding
THREAD_STATUS_MAIN_THREADflag missed from the docs.Hardly newsworthy, hardly testable but I think would be nice to backport to 3.15.
https://github.com/python/cpython/pull/154105/changes#diff-43a2fe1b7de3546d9e026fcf3664cdc0c35608385926a09e8038a84598acba30 addresses another issue in the document (
Total sample countis nowuint64.)