]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-152075: Avoid lock contention in _Py_Specialize_LoadGlobal under free threading...
authorPeter Hawkins <phawkins@google.com>
Fri, 31 Jul 2026 01:28:20 +0000 (18:28 -0700)
committerGitHub <noreply@github.com>
Fri, 31 Jul 2026 01:28:20 +0000 (01:28 +0000)
commitac8ba0ca5a04cd7b27b44822d31df640e817fd78
treefc279ccffe9689b227a8bdfe222e83c9e5a5acf2
parent22fed93a21c36c032d87629e66ea5d1eeeecc96e
gh-152075: Avoid lock contention in _Py_Specialize_LoadGlobal under free threading (gh-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.
Misc/NEWS.d/next/Core_and_Builtins/2026-07-14-20-19-48.gh-issue-152075.V9Rwhp.rst [new file with mode: 0644]
Python/specialize.c