Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-106597: Add debugging struct with offsets for out-of-process tools#106598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pablogsal merged 3 commits intopython:mainfrompablogsal:gh-106597
Jul 11, 2023

Conversation

@pablogsal
Copy link
Member

@pablogsalpablogsal commentedJul 10, 2023
edited by bedevere-bot
Loading

@pablogsal
Copy link
MemberAuthor

@markshannon Can you take another look?

@markshannon
Copy link
Member

I actually meant using pointers, so that the fields don't move. But this is fine.

I'm not the one using this. If it suits pystack, pyspy and austin, them I'm cool with whatever you want.

@pablogsal
Copy link
MemberAuthor

pablogsal commentedJul 10, 2023
edited
Loading

I actually meant using pointers, so that the fields don't move.

Ah, that would make retrieving these a bit more annoying because it would imply having to copy an extra pointer per structure group and also it makes initializing the runtime state more verbose so I would prefer to leave it as is.

@carljm
Copy link
Member

carljm commentedJul 10, 2023
edited
Loading

What are the backward-compat guarantees for this struct? Should we document them? I assume for this to be useful we should only ever add anything to the end of this struct, so that profilers don't have to have per-Python-version maps of the struct in order to be able to use the values in it correctly? (Also should we commit explicitly that this struct will always occur first in PyRuntimeState?)

And does that mean we commit to the future existence of all the struct fields with offsets listed here? Or if the struct field would be removed in a future Python, we'd set the offset to some kind of sentinel value without removing the entry from the debug-offsets struct?

EDIT: ok, I see now in the issue that there is no backwards-compatibility guarantee at all between minor versions. That also seems worth documenting, at least in a comment? There is already a comment saying the debug struct should stay first.

pablogsal reacted with thumbs up emoji

@carljm
Copy link
Member

carljm commentedJul 10, 2023
edited
Loading

FWIW, here's a list of offsets that we currently export from Cinder for use by our in-house out-of-process profiler (Strobelight), that are not currently exported in this PR:

offsetof(PyObject, ob_type)offsetof(PyTypeObject, tp_name)offsetof(PyCodeObject, co_flags)offsetof(PyTupleObject, ob_item)offsetof(_PyRuntimeState, gilstate.autoTSSkey._key)

Also, if we give an offset forPyCodeObject.co_localsplusnames, should we also give one forPyCodeObject.co_localspluskinds? Currently we useco_varnames which no longer exists as a field, to reconstruct it you'd need both names and kinds.

And if we expose an offset forPyThreadState.cframe, should we also explicitly give offsets for_PyCFrame.current_frame and_PyCFrame.previous? Otherwise you can't safely do much with thecframe value.

@pablogsal
Copy link
MemberAuthor

pablogsal commentedJul 10, 2023
edited
Loading

Also, if we give an offset forPyCodeObject.co_localsplusnames, should we also give one forPyCodeObject.co_localspluskinds? Currently we useco_varnames which no longer exists as a field, to reconstruct it you'd need both names and kinds.

And if we expose an offset forPyThreadState.cframe, should we also explicitly give offsets for_PyCFrame.current_frame and_PyCFrame.previous? Otherwise you can't safely do much with thecframe value.

I will add these to this PR 👍

carljm reacted with thumbs up emoji

@pablogsal
Copy link
MemberAuthor

That also seems worth documenting, at least in a comment? There is already a comment saying the debug struct should stay first.

Good point! Will update the PR tomorrow to include that comment.

carljm reacted with thumbs up emoji

@godlygeek
Copy link
Contributor

PyStack needs a few more fields than we have here. We also need:

  • native_thread_id from the thread state, for matching a C backtrace up to the Python thread it's for
  • locked andholder from the GIL runtime state, for checking whether a thread holds the GIL

@pablogsal
Copy link
MemberAuthor

FWIW, here's a list of offsets that we currently export from Cinder for use by our in-house out-of-process profiler (Strobelight), that are not currently exported in this PR:

I added all the offsets you mentioned for Strobelight exceptoffsetof(_PyRuntimeState, gilstate.autoTSSkey._key) which doesn't exist anymore

carljm reacted with thumbs up emoji

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@pablogsal
Copy link
MemberAuthor

@carljm I added the fields you mentioned and modified the comment. Could you please take a look?

Copy link
Member

@carljmcarljm left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you@pablogsal

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

Reviewers

@carljmcarljmcarljm approved these changes

@markshannonmarkshannonmarkshannon approved these changes

+1 more reviewer

@godlygeekgodlygeekgodlygeek left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@pablogsal@markshannon@carljm@godlygeek@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp