Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native_thread_id to PyThreadState #88045

Closed
P403n1x87 mannequin opened this issue Apr 17, 2021 · 2 comments
Closed

Add native_thread_id to PyThreadState #88045

P403n1x87 mannequin opened this issue Apr 17, 2021 · 2 comments
Labels
3.11 only security fixes topic-C-API type-feature A feature request or enhancement

Comments

@P403n1x87
Copy link
Mannequin

P403n1x87 mannequin commented Apr 17, 2021

BPO 43879
Nosy @pitrou, @vstinner, @P403n1x87, @shreyanavigyan
PRs
  • bpo-43879: Add native_thread_id field to PyThreadState #25458
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-05-26.14:40:40.186>
    created_at = <Date 2021-04-17.09:18:44.507>
    labels = ['expert-C-API', 'type-feature', '3.11']
    title = 'Add native_thread_id to PyThreadState'
    updated_at = <Date 2021-05-26.14:40:40.185>
    user = 'https://github.com/P403n1x87'

    bugs.python.org fields:

    activity = <Date 2021-05-26.14:40:40.185>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-05-26.14:40:40.186>
    closer = 'vstinner'
    components = ['C API']
    creation = <Date 2021-04-17.09:18:44.507>
    creator = 'Gabriele Tornetta'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43879
    keywords = ['patch']
    message_count = 2.0
    messages = ['391276', '394438']
    nosy_count = 5.0
    nosy_names = ['pitrou', 'vstinner', 'python-dev', 'Gabriele Tornetta', 'shreyanavigyan']
    pr_nums = ['25458']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue43879'
    versions = ['Python 3.11']

    @P403n1x87
    Copy link
    Mannequin Author

    P403n1x87 mannequin commented Apr 17, 2021

    I would like to propose adding the native_id field to the PyThreadState structure to store the result of PyThread_get_thread_native_id. On some systems, like Linux, it is not easy to retrieve this information from outside of the Python interpreter process.

    Tools like Austin (https://github.com/P403n1x87/austin) could benefit from this for CPU time sampling. Currently, if one wants to retrieve the TID from a PyThreadState instance is to regard thread_id as a pointer to a struct pthread structure, loop over all the Python threads to find the one that has the PID for TID and infer the offset of the tid field within struct pthread, which is not ideal.

    @P403n1x87 P403n1x87 mannequin added 3.10 only security fixes topic-C-API type-feature A feature request or enhancement labels Apr 17, 2021
    @P403n1x87 P403n1x87 mannequin changed the title Add native_id to PyThreadState Add native_thread_id to PyThreadState Apr 17, 2021
    @vstinner
    Copy link
    Member

    New changeset 90a6c07 by Gabriele N. Tornetta in branch 'main':
    bpo-43879: Add native_thread_id field to PyThreadState (GH-25458)
    90a6c07

    @vstinner vstinner added 3.11 only security fixes and removed 3.10 only security fixes labels May 26, 2021
    @vstinner vstinner removed the 3.10 only security fixes label May 26, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes topic-C-API type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant