mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-113743: Use per-interpreter locks for types (#115541)
Move type-lock to per-interpreter lock to avoid heavy contention in interpreters test
This commit is contained in:
parent
bce693111b
commit
454d7963e3
3 changed files with 5 additions and 4 deletions
|
@ -60,17 +60,18 @@ class object "PyObject *" "&PyBaseObject_Type"
|
|||
// in odd behaviors w.r.t. running with the GIL as the outer type lock could
|
||||
// be released and reacquired during a subclass update if there's contention
|
||||
// on the subclass lock.
|
||||
#define TYPE_LOCK &PyInterpreterState_Get()->types.mutex
|
||||
#define BEGIN_TYPE_LOCK() \
|
||||
{ \
|
||||
_PyCriticalSection _cs; \
|
||||
_PyCriticalSection_Begin(&_cs, &_PyRuntime.types.type_mutex); \
|
||||
_PyCriticalSection_Begin(&_cs, TYPE_LOCK); \
|
||||
|
||||
#define END_TYPE_LOCK() \
|
||||
_PyCriticalSection_End(&_cs); \
|
||||
}
|
||||
|
||||
#define ASSERT_TYPE_LOCK_HELD() \
|
||||
_Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(&_PyRuntime.types.type_mutex)
|
||||
_Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(TYPE_LOCK)
|
||||
|
||||
#else
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue