-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-subinterpreterstype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
We have a lock that we use for thread-safety when working with the set of interpreters: _PyRuntimeState.interpreters.mutex
. We use two macros in several core files to manage that lock: HEAD_LOCK()
and HEAD_UNLOCK()
(from pycore_pystate.h).
Recently we've begun using that runtime-global lock for thread-safety when working with a single interpreter's set of thread states (PyInterpreterState.threads
). The problem is that this means we are potentially blocking interpreters unnecessarily.
Thus it makes sense to introduce an interpreter-specific "head" lock: PyInterpreterState.threads.mutex
(plus corresponding macros).
Linked PRs
- gh-114940: Use fine-grained mutex protection for
PyInterpreterState.threads
#125561 - gh-114940: Add a Per-Interpreter Lock For the List of Thread States #127037
- gh-114940: Add _Py_FOR_EACH_TSTATE_UNLOCKED(), and Friends #127077
- gh-114940: Add a Per-Interpreter Lock For the List of Thread States #127115
colesbury, erlend-aasland and corona10
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-subinterpreterstype-featureA feature request or enhancementA feature request or enhancement
Projects
Status
Todo