Skip to content

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

Merged
kumaraditya303 merged 1 commit into
python:3.14from
miss-islington:backport-ac8ba0c-3.14
Oct 6, 2026
Merged

kumaraditya303 merged 1 commit into
python:3.14from
miss-islington:backport-ac8ba0c-3.14

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>
@kumaraditya303
kumaraditya303 merged commit 18ef0f0 into python:3.14 Oct 6, 2026
56 of 57 checks passed
@miss-islington
miss-islington deleted the backport-ac8ba0c-3.14 branch October 6, 2026 13:17
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.

3 participants