diff options
author | Dino Viehland <dinoviehland@meta.com> | 2024-02-16 00:28:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 00:28:31 (GMT) |
commit | 454d7963e31cded1de3a90642da7259848efd232 (patch) | |
tree | 4cb187f9ef42453b580095af98f9c094e4a70f30 /Objects | |
parent | bce693111bff906ccf9281c22371331aaff766ab (diff) | |
download | cpython-454d7963e31cded1de3a90642da7259848efd232.zip cpython-454d7963e31cded1de3a90642da7259848efd232.tar.gz cpython-454d7963e31cded1de3a90642da7259848efd232.tar.bz2 |
gh-113743: Use per-interpreter locks for types (#115541)
Move type-lock to per-interpreter lock to avoid heavy contention in interpreters test
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index e0711df..0118ee2 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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 |