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

Lock contention inside_PyType_LookupRef #132380

Open
Labels
@nascheme

Description

@nascheme

Feature or enhancement

Proposal:

As part of adding free-threading support to LibCST, we noticed there is a lot of lock contention onTYPE_LOCK inside the_PyType_LookupRef function. In the LibCST, the common "visitor" pattern is used. For example, in the_visitors.py module there is the code:

visit_func = getattr(self, f"visit_{type(node).__name__}", None)

The second argument togetattr() is a non-interned string and it causes the cached and lock-free path of_PyType_LookupRef() never to be taken. Instead, theTYPE_LOCK mutex is acquired on each lookup. This obviously scales very badly if there are multiple threads looking up class methods using this pattern.

Testing was done with Python 3.13 but I believe the same issue exists with 3.14.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp