Skip to content

[3.15] gh-152075: Avoid lock contention in _Py_Specialize_LoadGlobal under free threading (gh-153720) - #158905

Open
miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-ac8ba0c-3.15
Open

miss-islington wants to merge 1 commit into
python:3.15from
miss-islington:backport-ac8ba0c-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Under high thread concurrency in free-threaded builds, _Py_Specialize_LoadGlobal suffers from lock contention when acquiring the critical section mutexes for the globals and builtins dictionaries during bytecode specialization.

This PR skips LOAD_GLOBAL bytecode specialization if acquiring the two object mutexes would block.
(cherry picked from commit ac8ba0c)

Co-authored-by: Peter Hawkins phawkins@google.com

…nder free threading (pythongh-153720)

Under high thread concurrency in free-threaded builds, `_Py_Specialize_LoadGlobal` suffers from lock contention when acquiring the critical section mutexes for the `globals` and `builtins` dictionaries during bytecode specialization.

This PR skips LOAD_GLOBAL bytecode specialization if acquiring the two object mutexes would block.
(cherry picked from commit ac8ba0c)

Co-authored-by: Peter Hawkins <phawkins@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants